Closed iCodeForBananas closed 8 years ago
Interesting! Thanks for such a clear explanation.
If you have a way of setting up something like a codepen that I could use to diagnose this I'd be happy to look into it.
Something that jumps out at me immediately:
bullet.height = this.bulletHeight
bullet.width = this.bulletWidth
This is being set after enabling physics bodies for the particles of the emitter. Could it be that the body of each particle is larger than you expect? Perhaps you could find away to draw debug output for the bodies of currently alive particles, just to get a better visual of what's going on. Might be helpful to do the same for the tilemap at the same time.
Unfortunately the plugin itself doesn't yet have its own debug output for all the polygons and vectors involved in the collision handling, but that is on the roadmap for 0.2.0 (#4).
I was messing with the body width and height instead like you said. I think the main issue is that I'm unable to use overlap instead of collide with the bullets. I'll see if I can get a codepen together.
Some of the particles in the example have a similar issue. Change the collision on https://github.com/hexus/phaser-arcade-slopes/blob/gh-pages/src/ArcadeSlopesDemo.js#L300 to the below:
// Collide the particles against the collision layer
this.physics.arcade.overlap(this.emitter, this.ground, function(particle, ground) {
particle.kill()
}, null, this);
This should allow for the particles to come out of the player and when they overlap the ground be killed. Instead they get killed instantly inside of the player object.
Very interesting! I will absolutely investigate this at some point, thank you for highlighting it so well.
The plugin is probably not handling the overlapOnly
flag correctly. :)
Ok so I don't really understand the consequences of my actions but I got it to kind of work now.
Go to this line: https://github.com/hexus/phaser-arcade-slopes/blob/86c68867ca6ffce1c3a2cbe638571b199cc7c977/src/ArcadeSlopes/Overrides.js#L48
Replace the if statement with the following:
if (! overlapOnly && collideCallback) {
collideCallback.call(callbackContext, sprite, tile);
}
Hmm, okay. That's interesting, because that branch passes handling to Arcade Physics to handle normally, if the tile doesn't have a tile.slope
property (i.e. it hasn't been converted by the plugin).
Except the callback should still be called in the case of an overlap. The code you've linked to is meant to mirror this, to an extent:
https://github.com/photonstorm/phaser/blob/master/src/physics/arcade/TilemapCollision.js#L63
Except I decided to break it down a little more to avoid code repetition. But perhaps the return
statements I've used are causing issues down the line, or separateTile()
is doing something that I'm not catering for properly.
Also, love that the Lenny face is in the example GIF, haha. What do you use for screen capture?
LICEcap http://www.cockos.com/licecap/
One of the most useful tools ever for showing people stuff!
I totally managed to reproduce the issue above, but even after completely disabling the plugin. This might be an issue with Phaser itself, and not the plugin.
Okay, so this technically isn't a bug (but I think it is).
The callback is working as expected because the sprites are indeed overlapping a tile.
The problem, as highlighted in the GIF, is that these tiles shouldn't collide and have an index of -1, but Phaser doesn't say anything about overlap()
only checking tiles that collide. Whether this is correct is up for debate, but I feel like it isn't.
To work around this, you can add a process callback.
this.physics.arcade.overlap(this.emitter, this.ground, function (particle, tile) {
particle.kill();
}, function (particle, tile) {
return tile.collides;
}, this);
This will still check the overlap, but only for tiles that can collide. It should give the result you're after.
Collision process callbacks in Phaser are a check that let you decide whether to actually continue with the overlap/collision based on the result of your own callback function. In this case, we simply check whether the current tile is meant to collide with anything.
Feel free to let me know if this resolves all of your issues. :smiley:
Also, technically, this means my plugin is incorrect, because it will bail out from overlapOnly
collision checks if the tile doesn't collide, which is adverse to Phaser's above mentioned behaviour.
Oh, and thanks for showing me LICEcap, it's fabulous! :sparkles:
It totally worked! I didn't get a chance to really test it a lot but immediately I was able to shoot again! :)
Just a heads up for closure on this, it's works awesome! I updated the sprite bodies and added the processCallback to other things needing overlap and it all works! :)
Awesome, thanks for letting me know.
I did close this pre-emptively but I had a gut feeling that this was the cause of all your issues. I thought maybe something else would be causing the sliding/missing tiles, but assumed these were different attempts to get it working and ultimately you just wanted the correct overlap responses. :)
Glad it works so well! I look forward to seeing your project progress.
UPDATE
See down the conversation, the collide behavior looks like it's correct but you can't use overlap yet. https://github.com/hexus/phaser-arcade-slopes/issues/7#issuecomment-229096109
OLD The bullets hit the 50% slope and slide up.
The bullets go straight through and if you're shooting through a 10x10 the bullet will enter one side and collide with the opposite side.
This is how I create 50 reusable bullets.
This is how I fire a bullet.
This is how I collide bullets with the slope ground.
Normally I use overlap though.
but this has been happening.