My game is running slow.

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
dburdan
Posts: 104
Joined: Fri Jan 28, 2011 5:39 am

My game is running slow.

Post by dburdan » Sat Apr 23, 2011 8:29 pm

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

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Re: My game is running slow.

Post by BvG » Sat Apr 23, 2011 8:36 pm

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
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

dburdan
Posts: 104
Joined: Fri Jan 28, 2011 5:39 am

Re: My game is running slow.

Post by dburdan » Sat Apr 23, 2011 8:44 pm

Thanks BvG! I will try it out right now and let you know!

dburdan
Posts: 104
Joined: Fri Jan 28, 2011 5:39 am

Re: My game is running slow.

Post by dburdan » Sat Apr 23, 2011 9:14 pm

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.

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Re: My game is running slow.

Post by BvG » Sun Apr 24, 2011 9:32 am

Try working with lock screen. and increasing the distance moved at a time to more then one pixel.
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

Post Reply