AzraelTycka Posted May 16, 2015 Share Posted May 16, 2015 (edited) Hello, I'd like to ask for and advice. In the picture below is my current scene. On the right side I described my problem, I'll try to explain it here with words. I'm having blue sprite (blue rectangle) and number of green (grey dotted) sprites on both sides of the screen (black lines show where each sprit ends). I'd like the blue sprite to bounce of the green as a wall, but what I get instead is that whenever blue sprit hits the contact point/side it bounces backwards (described with purple arrows). If if hits in any other part of the green sprite then it bounces off correctly (discribed with red arrows).(green rectangles move downwards creating infinite lane - until some point of the level is reached when the green rectangles will stop at half of the scene in y-axis) I was wondering if there is a way how to turn this around in phaser? I though mayber creating some object which can get body and cover side areas with it (though don't know which part of phaser to use for it), or any other way please? Just for the record:I'm using arcade physics, phaser version 2.3.0. - blue rectangle: bounce(1,1) - green rectangles (phaser.group): bounce(1,1), immovable = true, velocity.y = 40 Thank you very much for any advice you can give me . EDIT:I'm currently using one pixel (picture) sprite with large body on both sides for collisions, and green rectangle sprites with velocity over it (they are not called for collision checks), but it still feels kinda weird to solve it like this. I hope someone can give me a better advice? :-) Edited May 16, 2015 by AzraelTycka Link to comment Share on other sites More sharing options...
devx123x Posted May 16, 2015 Share Posted May 16, 2015 Try setting bounce to (0,1) or a few other values. Maybe try (1,0). Link to comment Share on other sites More sharing options...
AzraelTycka Posted May 16, 2015 Author Share Posted May 16, 2015 Well I need the blue one to bounce of the brown one as well, and when the game gets to a certain part there will be needed bouncing in x and y directions off green ones as well, or did I get boucne property wrong? Link to comment Share on other sites More sharing options...
drhayes Posted May 18, 2015 Share Posted May 18, 2015 Maybe instead of moving the green sprites vertically, just animate the white stripes and keep them level with the what-look-to-me-to-be-Spy-Hunter-cars. So the green things don't move, don't collide with each other, and you don't have edge problems? Alternately, animate the white stripes moving but have invisible sprites to collide with so you don't have the edge problem? Link to comment Share on other sites More sharing options...
AzraelTycka Posted May 19, 2015 Author Share Posted May 19, 2015 Oh, the graphics are jsut stand ins, with stripes are there to be easily recognized when green sides are moving by eye :-), every green rectangle will be a different sprite eventually. Link to comment Share on other sites More sharing options...
drhayes Posted May 19, 2015 Share Posted May 19, 2015 Ah, okay. Do they always have 0 distance between them? Link to comment Share on other sites More sharing options...
ZoomBox Posted May 19, 2015 Share Posted May 19, 2015 You could:Try to make you "walls" colision sighly bigger (so the walls have some pixels on top of the next one, and you're sure you'll not have a gap between 2)Add a round shape to your moving object (a circle with a sighly bigger diameter than the current body) but it'll be a problem if you can hit something in front of youUse a custom shape (polygon): Basically a rectangle with cut angles like this _/ \| || || || |\_/ Link to comment Share on other sites More sharing options...
AzraelTycka Posted May 19, 2015 Author Share Posted May 19, 2015 drhayes:Distance is always zero, it's basically a "wall" made of different parts with different animations per part. ZoomBox:I had a similar idea as your first one, but the problem didn't disappear. I wanted to avoid custom collisions this time, I'm trying to heck it with phaser as much as possible to know it better :-). For now I added one more sprite per side (two in totals), gave them body and set its width to green rectangle and height to the whole world (screen) and collision is checked between these two and blue rectangle. Seems like in iteration blue rectangle partially overlaps with other bodies while it's not a problem when facing longer side of the rectangle it becomes a problem when it overlaps on a boundary where the collision is probably handled with bottom side (boundary) as well - probably :-). Link to comment Share on other sites More sharing options...
Recommended Posts