Sign in to follow this  

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)

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

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.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.