sanlegas Posted March 31, 2017 Report Share Posted March 31, 2017 Hi guys!, i am new by here, i have a couple of months works with phaser, i like it really !. Well lets go with my problem, i am programming a endless runner game, i want generate builds with different texture, i am using tile sprite for generate those builds, that is in a function for generate the builds with a random texture, the problem is when the new tile sprite is created affect to the tile sprite that was created previus to the new doing the previus tile sprite show the new texture for a Milliseconds and after back to his correct previus texture, i dont know what happend, my code is the next crea_edificio: function (x,width,height) { // body... console.log("creando edificio"); //this.crea_fondo(); var i_edificio = Math.floor(Math.random() * 5); var textura = Holk.TEXTURES[i_edificio]; var edificio = this.game.add.tileSprite(x, this.game.world.height - height,width * textura.width,height ,Object.keys(Holk.TEXTURES[i_edificio])[0]); this.game.physics.enable(edificio, Phaser.Physics.ARCADE); edificio.body.allowGravity = false; edificio.body.immovable = true; edificio.body.velocity.x = Holk.VELOCIDAD_SUELO ; edificio.update = function(){ //edificio.body.position.x = edificio.body.position.x - 2; //this.game.physics.arcade.collide(holk, edificio_grupo); if (this.body.position.x + this.body.width < 0) { this.destroy(); } } edificio_grupo.add(edificio); } this function is called every X seconds for other validation for generate a new build, I hope you can help me, thanks !!. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.