Creative COW SIGN IN :: SPONSORS :: ABOUT US :: CONTACT US
ADOBE DIRECTOR: HomeDirector ForumTagMotion Graphics

Re: scripting error for matching game

Cow Forums : Adobe Director
VIEW POSTS   •   ADD A NEW POST   •   SEARCH   •   CHANGE FORUM
Respond to this post   •   Return to posts index   •   Read entire thread


Re: scripting error for matching game
by William McGrath on Feb 13, 2009 at 7:40:05 pm

property myAleph
global gClick1, gClick2 --careful with this

on beginSprite me
gClick1=""
gClick2=""
--It was giving me a problem here, so to start with let's give
--the globals a value of "" (empty)

myAleph="א"
--It doesn't have to be myBeth, myShin or whatever:
--use the same property name for all. That way you can just
--copy and paste most of this, just assign a different letter
--to the property on this line and all the rest will work fine
--Another thing: I'm not sure about non-latin characters.
--Try it, but you might have to spell them out: "aleph", "beth"...
end

on mouseUp me
--First you assign the click to one of two globals
--What this means is: the sprite that was just clicked
--is the first or the second of a pair of clicks,
--so it says that in this case, gClick1= "א" or gClick2= "א" :

if gClick1="" then
gClick1=myAleph
else
gClick2=myAleph

--If it was gClick2 means you have a pair
-- (that's why you do this within the else clause)
--so you're ready to compare them to each other
-- to see if they're both the same
--(and either way you reset them for the next set of clicks:

if gClick1=gClick2 then
play "correct"
else
play "incorrect"
end if

gClick1=""
gClick2=""
end if

end mouseUp

--

And I think that's it. It works, as far as I've tested it, except for the Hebrew characters, but I don't know if that's my system or Director.

One other problem that you might want to address is what happens if you click twice on the same sprite. As it is now it'll always get a correct answer.
You might want to add a different pair of globals just to track this:
gSpriteClicked1, gSpriteClicked2

Then on the mouseDown you have to assign it the sprite number of the sprite clicked:
gSpriteClicked1=me.spriteNum

It would be the same procedure: set them to "", then if gSpriteClicked1="" assign the spriteNum to gSpriteClicked1, else assign it to gSpriteClicked2
Then, on the else clause of the above, right before you compare the gClick globals, compare these: if they're the same, play "error" or whatever.

Again, there are a million ways of doing this, I'm just suggesting one.

Let us know how it goes, OK?


---
william


Respond to this post   •   Return to posts index   •   Read entire thread


Current Message Thread:




Note: If you are a registered user please click here to login before posting.

Your post will not be accepted if your name and email address are not registered in our database. Click here if you do not have an account.

Name
E-Mail Address
Subject
E-Mail me when someone responds
Just This Message   Entire Thread   None  

Message:



Note: The following are HTML characters and may cause parts of your post to disappear if not used correctly: < > &
To include any portion of the post in your response, highlight the desired text and hit the "Q" key. Read more...



Add your message signature


 


Note: By clicking "Post Direct" button above, you are agreeing to the Creative Cow's Code of Conduct.



FORUMSTUTORIALSMAGAZINETRAININGVIDEOS - REELSPODCASTSEVENTSSERVICESNEWSLETTERNEWSBLOGS

© CreativeCOW.net All rights are reserved.

[Top]