Jump to content

Create animated sprite hiccup


Recommended Posts


I'm working on my first game with phaser. In the game I have a create function where I've put the following line:

this.cookieTimer = this.game.time.events.loop(Phaser.Timer.SECOND * game.global.cookie_rate, this.createCookies, this);

The function createCookies will set another function in motion which has the line, which seems to be the problem:

var cookie = this.cookies.create(game.width,game.height-100,'gameassets','cookie1/cookie1');

Everytime it 'creates' and adds to the group (this.cookies), the screen is paused for 1 second and continues after that.

Is this a bug? Or am I doing something wrong?

Any thoughts? 

Many thanks,




Link to comment
Share on other sites

What do you want to see?


Are you just creating more and more cookies that will never disappear?


I think the Problem is, that you are creating sprites at runtime (in the update-loop).

You should create all needed sprites in the create function of your game state.


So you could "pre-create" some cookies that you can use in your game.

Also reuse not needed sprites - when a cookie disappeares from your game (gets killed or something like that), reuse that sprite for a new cookie.


See this example: http://examples.phaser.io/_site/view_full.html?d=games&f=tanks.js&t=tanks

The bullets of the player are handled that way (see "Our bullet group" and the fire-function)


hope this helps :)

Link to comment
Share on other sites


  • Recently Browsing   0 members

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