Page 1 of 1

My game is running slow.

Posted: Sat Apr 23, 2011 8:29 pm
by dburdan
Hello,
I have made a game where a ball is moved to a location and back and you have to click as many dots as possible. However, it is running very slow and laggy which makes the game useless.

Right now, my code sends a move event to a graphic and then generates a certain amount of buttons. The user then has to click all the buttons before the ball reaches the end. Here is my move code:

Code: Select all

move graphic "ball" to 20,75 in 1000 milliseconds
switch the location of graphic "ball"
      case 20,75
         move graphic "Ball" to 20,445 in 800 millisecond
      case 20,445
         --Take points away depending on time
         answer "You scored" && score && "points!"
         resetGame
   end switch
Here is the code for generating the buttons:

Code: Select all

   repeat with i = 1 to jackNum
      create button
      put word 3 of it & return after jackList
      set the loc of button id (word 3 of it) to randomNum(xBounds[1],xBounds[2]), randomNum(yBounds[1],yBounds[2])
   end repeat
All works as planned except when there are more than a few buttons. It then runs extremely slow and renders the game unplayable. Any solutions would be much appreciated!

Thanks

Re: My game is running slow.

Posted: Sat Apr 23, 2011 8:36 pm
by BvG
don't use the move command. set the location yourself, using send in time strcutures.

for example:

Code: Select all

on draw
set the location of graphic 1 to item 1 of the location of graphic 1,  item 2 of the location of graphic 1 -1
send draw to me in 0.3 seconds
end draw

Re: My game is running slow.

Posted: Sat Apr 23, 2011 8:44 pm
by dburdan
Thanks BvG! I will try it out right now and let you know!

Re: My game is running slow.

Posted: Sat Apr 23, 2011 9:14 pm
by dburdan
So what if I want to move the ball to a location and back? At the start of the game, I want the ball to move to a location then back. Once it comes back the game is over. How can I accomplish this without the move command?

EDIT: I just figured out that part but my app is just as laggy as before. I am running it on iOS.

Re: My game is running slow.

Posted: Sun Apr 24, 2011 9:32 am
by BvG
Try working with lock screen. and increasing the distance moved at a time to more then one pixel.