Jump to content

Alternative to tileSprite + autoScroll() ?


cvshepherd
 Share

Recommended Posts

My game is currently suffering from poor performance on older mobile devices, when using the CANVAS renderer. One major reason seems to be that I am currently using five tileSprites in the game, for the autoScroll() functionallity. The problem being that autoScroll() spawns a new canvas when called, so I end up with a total of six, instead of one.

Is there a way to replicate the behavior of autoScroll on a normal sprite or image?

The reason I cant just move images around is that the images have a greater height than the game, and I'm only displaying them on parts of the screen.

 

Cheers

Link to comment
Share on other sites

All autoScroll does is change the tilePosition.x and/or tilePosition.y over time:

    if (this._scroll.x !== 0)    {        this.tilePosition.x += this._scroll.x * this.game.time.physicsElapsed;    }    if (this._scroll.y !== 0)    {        this.tilePosition.y += this._scroll.y * this.game.time.physicsElapsed;    }

So the issue isn't autoScroll but the fact that you're using TileSprites in general. If these are large and overlaid to create a parallax effect then you'll need to think about ways to optimise this, as you'll likely be creating a lot of overdraw; wastefully drawing pixels that then get covered up by other pixels. I replied to a post a while back on ways to reduce overdraw which should improve fps if done propertly: http://www.html5gamedevs.com/topic/7523-draw-to-bitmapdata/?hl=overdraw#entry44956

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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