Comments (13)
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. 😃
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.
from phaser-arcade-slopes.
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).
from phaser-arcade-slopes.
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. :)
from phaser-arcade-slopes.
LICEcap
http://www.cockos.com/licecap/
One of the most useful tools ever for showing people stuff!
from phaser-arcade-slopes.
Oh, and thanks for showing me LICEcap, it's fabulous! ✨
from phaser-arcade-slopes.
It totally worked! I didn't get a chance to really test it a lot but immediately I was able to shoot again! :)
from phaser-arcade-slopes.
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.
from phaser-arcade-slopes.
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.
from phaser-arcade-slopes.
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:
Replace the if statement with the following:
if (! overlapOnly && collideCallback) {
collideCallback.call(callbackContext, sprite, tile);
}
from phaser-arcade-slopes.
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?
from phaser-arcade-slopes.
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.
from phaser-arcade-slopes.
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! :)
from phaser-arcade-slopes.
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.
from phaser-arcade-slopes.
Related Issues (20)
- Automatically update sprite body polygons
- Remove the snap feature HOT 1
- Fix the wasTouching flags HOT 1
- Improve tunnelling HOT 12
- Ninja physics mapping for 64px+ HOT 1
- Fix skipped collisions between tiles HOT 3
- Prevent internal edge collisions without heuristics HOT 4
- AMD/UMD HOT 2
- Object pooling for calculations HOT 1
- Bodies not colliding HOT 2
- Automatically set colliding tiles for Tilemaps
- Drop Bower HOT 1
- Update npm package HOT 10
- Full-block tile in arcadeslopes not registering for collision HOT 4
- Using Slopes in Typescript HOT 20
- Question: How to prevent slipping or sliding on slopes HOT 1
- Curved slopes HOT 4
- Phaser 3 HOT 14
- Errors: "Unresolved slope type 'r' / Slope type r not defined", "tilemapLayer.getTileOffsetX is not a function" HOT 4
- Sprite jitters/bounces at some tile junctions HOT 14
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from phaser-arcade-slopes.