Jump to content

creating an object


peteblank
 Share

Recommended Posts

hey sorry for the n00b question, but I'm stuck.

function changeBlock (player, blocks)
    {
        if (player.y>blocks.y+40)
        {
            coin.create(block.x,block.y-40,'coin');
            this.sound.play('brick');
            blocks.destroy();
        }
    }

I got the player to be able to destroy the block when it jumps below it. 

But what I want is for the block to change sprite to the dud block and create a coin on top.

Link to comment
Share on other sites

If you are using separate textures for each sprite you can use blocks.setTexture('dud');

If you are using a texture with multiple sprites in it you can use blocks.setFrame('dud');

Then you can check at the start of the function against the texture or frame name to see whether to spawn a coin on collision.

 

Hope that helps.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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