Page 1 of 1

How to create an action determined by the order of mouse cli

PostPosted: Fri Sep 07, 2012 8:19 am
by seanie
Hello fellow NeoBookers,

I'm trying to create a vocabulary memory game for my students. To give you an idea of what I'm attempting to do, it's something like this:

http://www.2flashgames.com/2fgkjn134kjl ... /f-651.swf

I can make the objects, but I don't know how to make something happen if two objects are clicked on consecutively.

In other words, if students click on two LIKE objects, then they both disappear. I know how to make the objects 'disappear':-) What I don't know is how to write the command for If Object X is clicked immediately after clicking Object Y, then both Object X and Y disappear.

I hope I have explained myself clearly. If so, then I'd be grateful for any assistance.

Thanks for reading!

S

PostPosted: Fri Sep 07, 2012 9:07 am
by smokinbanger
To get started try something like:
Code: Select all
If "[Object1]" "<>" "Clicked"
   SetVar "[Obeject1]" "Clicked"
Else
    SetVar "[Object1]" ""
    .Allows the user to unclick an object
EndIf

IfEx "[Object1] = Clicked AND [Object2] = Clicked AND [Object4] <> Clicked AND [Object5] <> Clicked"
   HideObject "Object1" "None" "0"
   HideObject "Object2" "None" "0"
EndIf

That's one method, build on it from there. You may also consider using a clicked effect like shading the object;
Code: Select all
If "[Object5]" "=" "Clicked"
   SetObjectFill "Object5" "Silver" "Solid" "False"
EndIf

Another suggestion might be to use a separate array for each set of matching object to make it easier.

PostPosted: Fri Sep 07, 2012 9:22 am
by Gaev
seanie:

looks like you are trying to make games similar to ones I made years ago ... check out ...

http://www.scriptedlogic.com/IdenticoFreeSet1.htm ... Identico ... a pure memory game where user has to remember the locations of identical images

http://www.scriptedlogic.com/IdenticoFreeSet1.htm ... FiGORI ... where the user has to remember the locations of 'related images'

In both games, the user can choose to play with 9 sets of 2 images or 6 sets of 3 images.

Both are available for (free) download ... sorry, the source code is not included.

Re: How to create an action determined by the order of mouse

PostPosted: Fri Sep 07, 2012 2:12 pm
by dpayer
seanie wrote:Hello fellow NeoBookers,


I can make the objects, but I don't know how to make something happen if two objects are clicked on consecutively.
S


Another idea. Each object has a name. You can set a variable with that name (using the variable [self[) when the object is clicked and then connect the strings and look for your combination.

Example: Button1, Button2, Button3, Button4, Button5. You want to look for the Button3 then Button5 order.

Each button has an action for when it is clicked (as do many other objects). In that section of the action editor, place code similar to this:

Code: Select all
SetVar "[LastClicked]" "[Self]"
.add this name to the name of the last object clicked
SetVar "[ClickOrder]" "[ClickOrder][LastClicked]"
SearchStr "Button3Button5" "[Clickorder]" "[FoundRightOrder]" ""
If "[FoundRightOrder]" ">" "0"
   GoSub "Whateveryouwantdonenow"
Else
   .clean up the ClickOrder variable so it doesn't get too long
   SetVar "[ClickOrder]" "[LastClicked]"
Endif     



David P.

PostPosted: Fri Sep 07, 2012 8:14 pm
by seanie
Smokinbanger, Gaev, and David,

Thank you so very much! I'll be trying out your much appreciated suggestions this weekend.

S