Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!
I accessed the sheep herder game, code, pdf and video via the "hour of code" website and tutorials that are going on around the world at the moment. There is a problem with the intersect code from PDF 2 video 2
Line 9 gives a missing factor error (line 10 I corrected there was a missing bracket from the pdf); I have tried "bounds" "opaque pixels" and 255 without the quotes since I read they are not required anymore. I have read previous posts but can not find any more ideas. My LC version is 6.1.2 community ed.
Chris
on sheepGenerate -- Only just lines A B C of this generate new btns every mouseup
lock screen
repeat with x=1 to sLevel
repeat
clone btn "templateSheep" --A
set the name of the last btn to ("sheep" & x)
set the loc of last btn to random(320), random(480) --B
set the visible of the last button to true --C
if intersect (btn ("sheep" & x),grc "pen" , "255") is false and
intersect (btn ("sheep"&x), grp "groupControls" , "0") is false then
exit repeat
end if
delete btn ("sheep" & x)
end repeat
if the top of button ("sheep"&x) < the top of this card then
set the top of button ("sheep"&x) to the left of this card
end if
if the left of button ("sheep"&x) < the left of this card then
set the left of button ("sheep"&x) to the left of this card
end if
if the right of button ("sheep"&x) > the right of this card then
set the right of button ("sheep"&x) to the right of this card
end if
if the bottom of button ("sheep"&x) > the bottom of this card then
set the bottom of button ("sheep"&x) to the bottom of this card
end if
end repeat
unlock screen
end sheepGenerate
I should perhaps note that there are two too many 'end if's' in the sheepGenerate handler from pdf number 2. Just mentioning in case overlooked.
regards
chris
Believe me I have gone through the video lesson number 3 twice, have searched the forums. The problem now is that whenever I move the mouse inside the actual stack I get this error: can not set property, in the following where the location of the target is set to the mouse.
I understand the problem, but have no idea how to go about finding what exactly is wrong. The mouse entering the actual stack even before the start button is pressed means that the target is the stack, and not the sheep button. The cIsSheep property is in the button, it is set to true, the spelling has been checked. The sImASheep variable is declared at the top of the script. Everything appears to be in order. The pdf and my code do not differ.
on mouseMove
if sImASheep is true then
set the loc of the target to the mouseLoc
if intersect(the target, grc "pen" , 255) and the cIsSheep of the target is true then
set the backgroundcolour of the grc "pen" to "red"
else
set the backgoundcolour of grc "pen" to "blue"
end if
end if
end mouseMove
It sounds like you tested your mouseMove/mouseDown handlers before coding the required mouseRelease handler which puts puts "false" into sImASheep and in turn will alway execute the mouseMove hanlder.
What you will need to do is suppress messages within the LiveCode IDE (Message Icon in the toolbar), ensure you have the needed mouseRelease/mouseUp handlers and then enable messages again.
This should allow you to move the mouse about the stack without any error being thrown
Kind Regards
Neil Roger
--
RunRev Support Team ~ http://www.runrev.com
LiveCode – Realize fast, compile-free coding
Hallo Neil, No I can promise you that I had all that in already absolutely, I have been taking this very very slow to absorb every detail. However I can tell you that it works. I kept going through stuff over and over again. Once I posted the message to you I shut down LC completely (after 3 hours of it being up) and went to watch some programming videos. Just checked your message, re-started LC and then saw that everything is now working. So as always I put this down to something odd in memory because for example the mousemove handler was being activated even with the edit pointer tool, (not the edit Run tool), the groupedcontrols would move by themselves during this time. So basically LC needed to shutting down and now it works. Sorry to have bothered you, I usually shut down LC when things like this happen but just did not do it this time.
Kind regards
chris