Sign in to follow this  
peteblank

creating an object

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.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.