Jump to content

[PROBLEM] Generate Tile Sprite with different texture in same function when is called


Recommended Posts

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");
		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 

	    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 function is called every X seconds for other validation for generate a new build,


I hope you can help me, thanks !!.

Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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