Need help on keeping score

You have completed your first interactive designs with QuarkXPress 7, 8 & 9 and now have need for more advanced functionality. Discuss Expressions here, ask questions and learn more about them.
Please note that Flash (SWF) authoring is not supported in QuarkXPress 10 anymore.
S57
Posts: 0
Joined: 08 Aug 2011, 10:04

Need help on keeping score

Post by S57 » 08 Aug 2011, 05:27

Hi, I have tinkered around with the interactive features of Quark 9 so I am becoming more familiar with the interface. After browsing the forums and help guides, I am still stuck on an issue I am having and was wondering if someone could maybe help out.

I am basically making a game and need to keep score. All I want to do is have an UP arrow, and a DOWN arrow that when clicked, a score (which is a separate text box) increase/decrease by 100 increments. I would like to score the start at Zero with the possibility of going into negative numbers: -100, -200, -300, etc.

I am assuming I would need an expression for this? If so, what would that expression be and how do I assign it?

Thanks in advance for any tips.

Matthias Guenther (Quark)
Quarkian
Quarkian
Posts: 2490
Joined: 04 Jun 2004, 15:06
Contact:

Need help on keeping score

Post by Matthias Guenther (Quark) » 10 Aug 2011, 02:43

Hi S57,
it is quite easy. Yes, you need soem expressions, nothign complicated though. Here's how:
Prereqs:
- Create an integer variable that golds your score, let's call it score.
- Create a text box that shows the score, let's call it scorebox. It needs to be a textbox object.
- Create your two arrows to increase and decrease the score.
- Create three scripts, one is "Initialize", one "Increase", one "Decrease".
- Your page needs to run the "Initialize" script and the two arrows the two other scripts (when clicked).
Creating expressions:
- Your "Initialize" script will only need one expression. Expression > Set "score = 0".
- Your "Increase"script will have two expressions, first is Expression Set > "score = score + 100" (or whatever you want to increase it by).
Then a normal action "Object > Reset > scorebox"
Then a second expression Expression > Set "scorebox.Append(score)
- Same three actions for the "Decrease" script, just with - 100.

Does that work?
Thanks
Matthias

S57
Posts: 0
Joined: 08 Aug 2011, 10:04

Need help on keeping score

Post by S57 » 15 Aug 2011, 08:39

Hi Matthias,
Thanks for the help, but I have a couple more questions. Again, I am a total noob at programing so I appreciate your patience.
After reading your description, I was able to figure out everything by clicking through Quark's many different options. However, I was unable to get the initialize script to show a 0 when the program launches. I got the score=0 script to validate, it just isnt appearing when the program starts.
I created a textbox called scorebox and created an interger variable called score. But I just can't get the text to show up in this scorebox when the program starts up even after assigning this script to the page.
I guess my question is, how do I get the score to show up in the score box? In the Expression Editor, just having"score=0" let's me click the OK button without getting an error message. But if I double click on the Scorebox text in the Objects section of the Expression Editor first, I get the error mesage of "The scoreboxscore variable does not exist. Do you want to define it now?".
I am probably just missing something simple to get the score actually pop up in the score box. Any suggestions are appreciated (And again, I am a noob so detailed step by step instructions would save me hours of frustration).

Matthias Guenther (Quark)
Quarkian
Quarkian
Posts: 2490
Joined: 04 Jun 2004, 15:06
Contact:

Need help on keeping score

Post by Matthias Guenther (Quark) » 15 Aug 2011, 21:54

Hi S57,
luckily you don't need to program, it is "just" scripting, so if you know for example AppleScript, concepts like variables would be very well known to you. Maybe this eSeminar helps to understand it better: http://bcove.me/zn7n35mk
Back to your project:
You need to tell QuarkXPress that a certain name is a variable and what it will hodl (objects, text, numbers etc.).
So you first you shoudl go intio Edit > Variables and create a new variable called "score" and type integer. Now you can use it in your new script, call it "Initialize" and set the expression to "score=0".
To make sure it runs once and as the first thing, the script "Initialize" needs to be the page entry script (in page tab for your page).
Then it will work.
To show the score 0 you could add another action to your "initialize" script, which will be
Expression > Set "scorebox.Append(score)"
Does it work now?
Thanks
Matthias

S57
Posts: 0
Joined: 08 Aug 2011, 10:04

Need help on keeping score

Post by S57 » 16 Aug 2011, 04:27

Hi Matthias,
Yes! This worked. Thanks for the help.
However, I am getting an error during the Increase/Decrease script. The "Object > Reset > scorebox" expression doesnt seem to be working (I get the "The Reset variable does not exsist. Do you want to define it now?" pop up error message). If I click on Define, the Edit > Variables box pops up with the "score" set as an integer box appears. So I guess that is why I am confused because I thought this would work...

Right now when I click the Increase Arrow, the scorebox starts at 0, then the number 100 pops up right behind it, then 200, then 300. So if I click the up arrow 4 times, the number "0100200300400" pops up in the scorebox. Hence, this is the why I need that RESET expression. I assuming I did something simple wrong, but I just couldnt get that Reset expression to work. Any thoughts? Did I just mistype something...?
Thanks in advance.

Matthias Guenther (Quark)
Quarkian
Quarkian
Posts: 2490
Joined: 04 Jun 2004, 15:06
Contact:

Need help on keeping score

Post by Matthias Guenther (Quark) » 16 Aug 2011, 04:31

Hi S57,
glad it works so far.
About the last bit, there's a slight misunderstanding: Object > Reset is not an Expression, it is an action under the Object action sets (so a popup menu).
Thanks
Matthias

S57
Posts: 0
Joined: 08 Aug 2011, 10:04

Need help on keeping score

Post by S57 » 16 Aug 2011, 04:57

You are correct, I just read your first posting wrong. Thanks for the clarification.
However, now when I click on the Up Arrow, it stays at 0 instead of increasing by 100 each time the up arrow is clicked. .

My on Click Up script has the 3 things running inside it: score = score + 100 expression, the reset object scorebox event, and the set scorebox.append(Score) expression.
Thoughts? (Thanks again for helping a newbie out).

Matthias Guenther (Quark)
Quarkian
Quarkian
Posts: 2490
Joined: 04 Jun 2004, 15:06
Contact:

Need help on keeping score

Post by Matthias Guenther (Quark) » 16 Aug 2011, 05:04

Hi S57,
I can only imagine that your score=0 action runs somehow, how do you run this?
And, do you have Score and score (case-sensitiveness) defined? (You shouldn't)
Thanks
Matthias

S57
Posts: 0
Joined: 08 Aug 2011, 10:04

Need help on keeping score

Post by S57 » 16 Aug 2011, 05:20

No, I do not have Score or score as case sensitive.
I only have the two scripts running. The first is assigned to the UpArrow as described in my previous post.
The second is just the Inititialize script which is set to the page. This has the "score=0" and the "scorebox.append(score)" expressions assigned to it.
And in the Edit > Variables box, I simply have "score" set to Type = Integer as you previously instructed.

Perhaps it is only recognizing the Inititialize script...? Maybe the scorebox.append(score) expression in Inititalize script needs to be shut off to allow the UpArrow scorebox.append(score) expression to function properly???
Any other suggestions? Thanks again.

Matthias Guenther (Quark)
Quarkian
Quarkian
Posts: 2490
Joined: 04 Jun 2004, 15:06
Contact:

Need help on keeping score

Post by Matthias Guenther (Quark) » 16 Aug 2011, 22:09

And the second one is the Page Entry Script for your page?
Maybe you can send me your file, it will make it easier to find ou the cause.
Thanks
Matthias

Locked

Return to “Expressions”