Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Something messing timings in game


Recommended Posts

Hello, I have a larger project using P2 physics with many tweens and the game sometimes moves randomly, some objects have some delays etc, even when game runs on almost stable 60fps. I've made a simple example in Phaser 2.4.6:


var level = 1;

intro = function(game) {};

intro.prototype = {

	create: function() {
		this.stage.backgroundColor = "#ffffff";
		game.time.events.add(2000, this.spawnWater, this, 4);

	spawnWater: function(amount) {
		for (var i = 0; i < amount; i++) {
            var topwater = game.add.sprite(683, 150, 'graphics2', 'static/smth/line.png');
			topwater.scaleTween = game.add.tween(topwater.scale).to({x: 1, y: 1}, 2000, Phaser.Easing.Cubic.In, true, (i*500), -1, false);
			topwater.positionTween = game.add.tween(topwater.position).to({y: 670}, 2000, Phaser.Easing.Cubic.In, true, (i*500), -1, false);	

What should it do :
- after 2 seconds it should spawn 4 lines
- each line has 2 tweens, for scale and position.
- tweens starts after 0, 500, 1000 and 1500 ms and they are looped infinitely (so they start again from starting values.
- there should be line moving from y = 150 to y = 670 every 500 ms

How does it work:
When reloading the game sometimes the lines are moving correctly (that means every 500ms there is a line), but sometimes after first 4 lines there is longer gap (longer than 500ms) and is messing the way the lines are moving.... What is wrong?

delay times in tweens were wrong, fixed it from (i+1)*500 to (i*500)

Link to comment
Share on other sites


  • Recently Browsing   0 members

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