Jump to content

Player colliding sideways with ground tiles


Max
 Share

Recommended Posts

Hi everybody!

 

I heard of the awesome features in the new Phaser-release through Twitter yesterday, so I really wanted to play around with it a bit. I'm currently experimenting with a simple platformer (click to play).

 

I'm using Phaser version 1.1.3.

 

The ground is made up of multiple blocks:

this.floorTiles = this.game.add.group();for (var i = 0; i < worldWidth; i += 64) {	var brick = this.floorTiles.create(i, worldHeight - 32, 'brick');		brick.body.immovable = true;		brick.body.allowGravity = false;}

The player collides with them vertically just fine, but also horizontally if you start moving left.

 

I know that this is a common problem with collision systems and each implementation/engine has its own way of going around this. How can I avoid this unwanted horizontal collision in Phaser?

 

Also: I can't jump if I'm on the ground – jumping in the air works, though (press SPACE). Any idea on how to solve this aswell?

if (this.cursors.jump.isDown && true) {	this.body.velocity.y = -500;}

Full code: game.js / player.js

 

Thank you very much for your help. I'm enjoying Phaser quite a bit already, I just need a little help getting started. Thank you! :)

 

Max

Link to comment
Share on other sites

Hey rafaholiveira, thanks for your help. :)

 

I checked the documentation for TileSprites but it unfortunately does not look like it's an option because I need each block to stuff individually. I want to make single blocks disappear or move up and down. Does the tilemap allow for this sort of behavior while preventing the toe-stubbing?

 

Thanks,

Max

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.

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

  • Recently Browsing   0 members

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