Ok. I have a game that is all about how long you can survive. The score goes up by three for every second you can last. However, if you go to menu and then start a new game again it increases by six. If you go to menu and back it goes to nine. Why is this?
Here is the score code:
score = 0;
function addScore(e)
score=(score +3);
scoreNumbText.text = score;
end
time2 = timer.performWithDelay(1000, addScore, 0) [import]uid: 49677 topic_id: 8754 reply_id: 308754[/import]
Hmm for some reason everything i try doesnt work. Is there anyway that by going to the Menu scene that i can delete the Game scene and make it create a new one upon choosing to play the game?
The game works fine… its just the problems when going out to the menu and trying to play again [import]uid: 49677 topic_id: 8754 reply_id: 31938[/import]
yes… that’s where the magic of director class will do for you, but you’ll have to put everything into the local Group.
is the error still the same or is it different now?
[lua] local localGroup = display.newGroup()
function new()
– example
image1 = display.newImageRect(“image.png”, 50,500
image1.x = 50
image1.y = 50
localGroup:insert(image1)
– in my game I used clean instead of cleanUp
clean = function ()
– code goes here
end
return localGroup
end
– and that should be it… unless you messed up somewhere in your
– code, then it might create a problem, but without seeing the
– rest of your code, I can’t tell. [import]uid: 12455 topic_id: 8754 reply_id: 31943[/import]
Well ive changed it so that you cant exit the game anymore. I am still having trouble making the game stop though.
If (playGame ~= false) then
the gamepeice follows the mouse drag
if(gamepeice.y <0) then
playGame= false;
print(“stuff”)
end
end
the problem im having now is that, the gamepeice will go out of the range to keep the game going, “stuff” will print in the terminal window, but the game wont stop. makes no sense whatsoever
My ship starts at like 500,600. If the ship.y <600, then play ready = false and it will print what i tell it to
if i say If ship.y <400, and then move the above 400, it wont print and apparently isnt registering that the y has changed
how do i check for a change in the y, there for making the game stop? [import]uid: 49677 topic_id: 8754 reply_id: 31982[/import]