Hi, I’ll try to explain you where I’m stuck:
In this game I’m trying to create, you have to bring all the sheeps into a fence and, if you’ll do it before time runs out, the game will end.
What am I supposed to do for this action? I need a sort of counter so when all the sheeps are in the fence I can put an action and make the game end.
I’m new with this program, just be patient Thanksss
I have adapted the script from this thread for our sheep management task:
At the bottom of the function “intersectTest” script is where the “sheep tracking” code is placed. Please see “Fig.1” at the bottom of this post.
We create an array in the “Head HTML”: sheepTotal = [ ]; We will use this array to track our sheep.
Each sheep has an ID number, for example: sheep-1.
As the sheep are added to the pen they have their “pointerEvents” property set to “none” so they cannot get loose out of their confine! As each sheep is added its “name” shows up in the “sheepAlert” (ID) text box.
Every time a new sheep is added the length of the “sheepTotal” array is checked. If the length (e.g. number of sheep) equals “5” - which is the total number of our sheep - then the text ‘All the Sheep are in!’ shows up in the “sheepAlert” (ID) text box.