Jump to content

Very slow, why?


i3Designer
 Share

Recommended Posts

The large semi-opaque scrolling background will probably slow some devices down, so if you can instead change the colour of the background to what it is in the game, and reduce the size of it (chop off the bottom half which is just solid black) you reduce the amount of pixels the game has to draw on the screen (the 'fill rate', a limiting factor on many devices).

 

From a code point of view, try to reduce the amount of collide and overlap calls as much as possible, and put your logic inside the callback depending on which two objects collide - each call to collide and overlap is fairly expensive. Also, turn off advanced timing as this can slow your game down somewhat. Finally, try not to update this.text every frame - do it only when necessary, i.e. when the text actually gets changed. The Phaser.Text object has a check in place to ensure it doesn't do anything unless the incoming text is different from the current text, but it's still a good general practice to bear in mind; there should be as little waste as possible, and you should strive to ensure only code that is absolutely necessary is being executed. 

 

Most of the above can be tested to see how effective they'll be by just changing bits of your code/commenting stuff out. For instance, get rid of the scrolling background and see how much that improves performance; remove the collide/overlap checks for the falling block; remove the score text etc etc.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...