vincent.tulip Posted April 12, 2015 Share Posted April 12, 2015 when i click to create new sprite,it stuck may be 500(ms),how can i fix it? i use Phaser v2.2.2var names = ["snow1", "snow2", "snow3"]; this.game.input.onDown.add(function () { var x = this.game.input.mousePointer.x; var y = this.game.input.mousePointer.y; console.log("x:" + x); console.log("y:" + x); var name=names[Math.floor(Math.random()*3)]; var tmpImage = this.game.add.sprite(x, y,name ); snowsGroup.add(tmpImage); this.game.physics.arcade.enable([tmpImage]); tmpImage.body.gravity.y = 200; tmpImage.checkWorldBounds = true; tmpImage.outOfBoundsKill = true; }, this); Link to comment Share on other sites More sharing options...
Milton Posted April 12, 2015 Share Posted April 12, 2015 Maybe you want a start velocity? Gravity has to do its work first... Link to comment Share on other sites More sharing options...
vincent.tulip Posted April 12, 2015 Author Share Posted April 12, 2015 var names = ["snow1", "snow2", "snow3"]; this.game.input.onDown.add(function () { var x = this.game.input.mousePointer.x; var y = this.game.input.mousePointer.y; console.log("x:" + x); console.log("y:" + x); var name=names[Math.floor(Math.random()*3)]; var tmpImage = this.game.add.sprite(x, y,name ); //snowsGroup.add(tmpImage); //this.game.physics.arcade.enable([tmpImage]); // tmpImage.body.gravity.y = 200; //tmpImage.checkWorldBounds = true; // tmpImage.outOfBoundsKill = true; }, this);i change this,but the result is no change Link to comment Share on other sites More sharing options...
Recommended Posts