Score update on every page

Hey everyone,

What I have is a car purchasing game that involves a lot of different pages for each type of car. Most of the pages involve buttons that when they click on them it will put a value into the score display that I have already made. I was wondering what code do I need to use so that when they click the button it will add one to the score but then when they hit it again it will take the score away.

I am also using the director class so that I can switch from scene to scene. This is the biggest problem because I know how update the score on one mouse click on one page but then when I get to the next page I want the same score to show up and this pages buttons to add on to the previous score?

Does this make sense to anyone haha?

Thanks for any help [import]uid: 153468 topic_id: 28100 reply_id: 328100[/import]

I understand the part about making the score the same across pages - you either want to make it global or save and load it using something like Ice, Ego or Jon Beebe’s Games class.

Peach :slight_smile: [import]uid: 52491 topic_id: 28100 reply_id: 113625[/import]

Thanks for answering but I am super new at all of this corona and lua stuff. Could you put that into more beginner terms and maybe add a little more explanation/code? Thanks [import]uid: 153468 topic_id: 28100 reply_id: 113642[/import]

I’m a little short on time today (it’s Saturday after all) but if you tell me what you’ve currently got setup I can offer some insight. As in, do you have a game scene and a gameover scene? Do you already have a score in the game scene?

Let me know and will do my best to assist you - worst case scenario if you bump this on Monday I can try to put together some simple code for you then.

Peach :slight_smile: [import]uid: 52491 topic_id: 28100 reply_id: 113711[/import]

I dont have a game over scene because its not really a “game” in a way. What it does now it I have every button set to a value and also set to another page link. So what happens is when you click the button it takes that value and changes pages at the exact same time and it project the score value on the page that you are linking to. This is working fine for now but I now have a “radio button” page where I have the buttons not linking to a page anymore because you can click on more than one. It just has one button on the bottom that says submit and takes all of the values. So what I need is a something that will make it so when you click the button the image will switch to the checked radio button and the value will be added to the score variable. But then when it is clicked again the value will be taken out. Hope this makes some sense. Thanks for the help! [import]uid: 153468 topic_id: 28100 reply_id: 113915[/import]

Hey John,

OK, interesting. I can’t quite picture what you are doing but I’d still very much like to help you. If you aren’t changing scenes/screens I am not sure why the value is being cleared - alternatively, perhaps you ARE changing and I’ve misread the above due to the lack of a “game over” scene.

I have limited time for things like this as it isn’t technically part of my duties with Corona, however if you wanted to email me a zip of your project at peach[at]coronalabs[dot]com I’d be happy to try and find a little time to take a look.

Alternatively if you have concerns about keeping your work private you could perhaps provide a “sample” project, a cut down version of your actual project, and I could check that out.

Please do let me know - I know it can be frustrating not being able to move forward and would very much like to assist if I can.

Peach :slight_smile: [import]uid: 52491 topic_id: 28100 reply_id: 114043[/import]