Page 1 of 1

sheep herder game Cant grab sheep.

Posted: Thu Apr 10, 2014 2:47 pm
by apprentice12
Dear community.

I have been studying the lessons from the academy courses but i am getting stuck .

Here is the code that i got from the lessons. Can you tell me what is wrong ?

Local sImASheep


on mouseDown
if the cIsSheep of the target is true then
put true into sImASheep
end if
end mouseDown

on mouseMove
if sImASheep is true then
set the loc of the target to the mouseLoc
if intersect (the target, Graphic "pen", 255) and the cIsSheep of the target is true then
set the backgroundcolor of the graphic "pen" to "red"
else
set the backgroundcolor of the graphic "pen" to "blue"
end if
end if
end mouseMove

Re: sheep herder game Cant grab sheep.

Posted: Thu Apr 10, 2014 10:29 pm
by MichaelUK
This is what i have mine works fine i think it could be the intersect line is the problem you have it split across two lines
did you also declare slmAsheep as a local var at the beginning of the code?

on mouseDown
if the cIsSheep of the target is true then
put true into slmASheep
end if
end mouseDown

on mouseMove
if slmASheep is true then
set the loc of the target to the mouseLoc
if intersect(the target, Graphic "pen", 255) and the clsSheep of the target is true then set the backgroundcolor of the graphic "pen" to "red"
else
set the backgroundcolor of the graphic "pen" to "blue"
end if
end if
end mouseMove

hope this helps
Michael

Re: sheep herder game Cant grab sheep.

Posted: Fri Apr 11, 2014 9:24 am
by apprentice12
Hi Michael.

Thank you very much for your reply.


Unfortunately the problem remains and yes i have declared the local sImAsheep in the top.

Maybe there is a bug on the version that i am using.

Have you uploaded your stack somewhere so i can download it ?

Thanks

Re: sheep herder game Cant grab sheep.

Posted: Fri Apr 11, 2014 3:57 pm
by Simon
http://revonline2.runrev.com/stack/528/ ... -device%29

Sorry on mobile. But there it is.

Simon