Closed jcd-as closed 10 years ago
I suspect these are all delta timer related, it's the only thing that makes sense re: object tunnelling.
meaning time.physicsElapsed time? I assumed this was the issue at first, but I hard-coded it to 0.166 in Time.js and the issues still reproduce
the sprite->tile separation routines are using hullX and hullY rects to determine overlap and do separation, but the hullX and hullY rects weren't updated when sprite->sprite separation occurred. so if a sprite pushed another sprite into a tile, the second sprite wouldn't separate properly from the tile and could end up "inside" the tilemap, where all kinds of weird things would then happen.
framerate issues seem to have been a red herring (or possibly a separate issue, since I still see odd things happen with collision/tilemaps at low framerates)
there could still be some odd ordering issues - I had to make sure that the order I check collisions in was sprites<->sprites first and then sprites<->tilemaps
Now that makes a lot more sense, thanks for the digging. I will play with this today. Collision order shouldn't be an issue once this part works I would hope. Also we've just started work on integrating p2.js and it's going really well, so I'm looking forward to offering that as a solution around version 1.1.4 - 5.
physics interactions between sprites seems to have some issues, particularly when combined with tilemaps - sprites can become embedded in "solid" tiles, pass through each other etc
this is most easily illustrated by adding another sprite to the 'starstruck' sample. e.g.:
to the 'preload' function, add the line
add a var named 'ball' to the file,
then to the create function, add:
and finally to the update function add collision-handling for the new sprite:
'kick' the ball around a bit, particularly into corners and such, and you'll notice that you can sometimes force the ball or the player into walls, floors, each other, etc. (tweaking the bounce, drag and gravity of the sprites can make it easier to get some of these to occur, but it's not too difficult. getting the ball down into the bottom left area and pushing it around / jumping on it usually does the trick).
I've been trying to track this down, but haven't had much luck yet - it's quite a pain to debug. hoping that those with more intimate knowledge of the update, collision and separation logic may have some ideas.
(note that these occur on a laptop that keeps a steady framerate of about 60 fps, but things seem to get much worse when the framerate gets lower/choppier, as on mobile devices)