This content has been marked as final. Show 5 replies
I would do this by making a list of each of the sprite numbers for any
given member. For instance sharks = [2,3,4,5] rabbits = [6,7,8,9,10].
And then when the user clicks on any of those sprites, remove that
sprite number from the list. When the list is empty, they have all of
Adobe Community Expert
are the pictures with the animals single images or are they going to be comprised of several images placed over each other?... if it's a single image then you may be interested in this link:
They are single images, e.g imagine like a wheres wally type layout which is comprised of lots of different object - in this case animals, for the first section you must find 3 different sharks and when you click on 3 of them you can then continue to the next chapter e.g find 4 stripy fish....and so on....
Cheers for that but....
Where should I create the instance of these sharks and rabbits is it on the image or should I create a new variable?
do I use mouse event handler to remove the sprite number from the list?
Assuming each of your 'clickable' objects are sprites (eg you have a graphic for a single shark which you have dragged on to the stage), then you could add a behaviour like this to each of these clickable sprites:
on CollectObjects(me, aList, id)
if (myType = id) then
if not (aList.getOne(me))then
-- if this object not in the list, then join
on getPropertyDescriptionList me
pdlist = [:]
-- set an id for this sprite
alist = [#type:#symbol, \
#comment: "What kind of thing is this", \
#range: [#shark, #tuna]] -- add ids for the other objects here
-- add to the pdlist
pdlist[#myType] = alist
on mouseDown (me)
-- tell everyone that this object has been clicked!
sendAllSprites(#ObjectHasBeenclicked, me, myType)
Note - in the getPropertyDescriptionList method is a list with [#shark, #tuna]. Add all your other object types here. Each time you drag this behaviour on to a sprite, select the object type in the dialog that pops up (the 'getPropertyDescriptionList dialog').
Next step is to add the following behaviour to the frame script channel. This behaviour controls the game logic. Hopefully the comments will explain how it works:
on exitFrame me
-- loop in the current frame
go to the frame
on beginSprite (me)
AllObjectTypes = [#shark, #tuna]-- add ids for the other objects here
CurrentObjects = 
if count(AllObjectTypes) > 0 then
-- determine the type of object for this round
CurrentObjectType = AllObjectTypes
-- remove the selected type from the list
-- now collect a list of all these objects
CurrentObjects = 
sendAllSprites(#CollectObjects, CurrentObjects, CurrentObjectType)
alert ("Game Over!")
on ObjectHasBeenclicked (me, obj, objtype)
-- has the object that has been clicked the right type?
if CurrentObjectType = objtype then
-- if so, is it in our list
if CurrentObjects.getOne(obj) then
-- delete it from the list
-- check that we have deleted all the objects
if count(CurrentObjects) =0 then