nkholski

Generic platformer + ES6 / Webpack 4 boilerplate

Recommended Posts

Hello nkholski.  I love what you are doing with collisions in the game. when Mario is small and he jumps up to hit a brick, what part of the code makes the tile bump up and come back down again?

Thanks

 

 

Share this post


Link to post
Share on other sites

You have to dig in the code and that part is a bit messy I think. A callback is fired when Mario collides with a tile, if he moves upwards and the collision is from above it will hide the tile and put a sprite at its position which is tweened up and down. When the sprite has returned to the original position it's removed again and the tile is made visible (don't remember if I use alpha on the tile or something else for this). The sprite is called SMBTileSprite which is a stupid name not to confuse with Phasers tileSprites. The implementation isn't that great. If I remember correctly there can currently only be one sprite of this kind, and this sprite should be in a pool to allow multiple simultaneous animations.

Share this post


Link to post
Share on other sites
11 minutes ago, blackhawx said:

Your description in the process was all I needed to know.  Makes perfect sense.  Thanks for breaking that logic down!

  

Yes. One pro with this approach that while the tile is replaced with a sprite it's trivial to check collision between that and other sprites allowing you to jump under enemies and destroy them. Right now crushing a brick won't kill an enemy above the brick because I just remove the tile. This could be solved to do exactly as when bumping the brick but setting the alpha of the temporary sprite to 0.

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.

Guest
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.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.