hollowdoor Posted March 10, 2015 Share Posted March 10, 2015 What facilities does phaser have for using lines created from interpolation as boundaries for collisions? Link to comment Share on other sites More sharing options...
hollowdoor Posted March 11, 2015 Author Share Posted March 11, 2015 I think I may be wrong about what I mean. Interpolation would be more for tweening. I'm asking if there is a way to use a curve as a shape that can have collision? Link to comment Share on other sites More sharing options...
valueerror Posted March 11, 2015 Share Posted March 11, 2015 you can use any polygon as collision shape in phaser if you use p2 physics Link to comment Share on other sites More sharing options...
hollowdoor Posted March 11, 2015 Author Share Posted March 11, 2015 What about dynamic in game created polygons? I've already found a tutorial on handmade polygons, but I'm looking for a way to use dynamically created ones.you can use any polygon as collision shape in phaser if you use p2 physics Link to comment Share on other sites More sharing options...
valueerror Posted March 11, 2015 Share Posted March 11, 2015 the usual way would be to create a json file with the information about the polygon (the coordinates of the points)i'm sure i already saw an example on how to feed the information about the polygon to phaser by an array.. the content of that array can be dynamically created of course.. ZoomBox 1 Link to comment Share on other sites More sharing options...
ZoomBox Posted March 11, 2015 Share Posted March 11, 2015 +1You can also change your object's shape during the game but you'd have to check for collision problem (object that appears to be inside others after a body shape update). Link to comment Share on other sites More sharing options...
hollowdoor Posted March 11, 2015 Author Share Posted March 11, 2015 Oh. Here is how to do it. I gotta search the docs better. I can generate my point arrays, and give them to a bitmap data object for a texture. The bitmap data can be used as a sprite, and I can give that same point array to addPolygon of the P2 body of the sprite. How about that? Turns out it's not so hard. Now I don't know if this should be a question warranting a new thread. Is there a way to clip a sprite's image with a polygon? This would be useful to cut every part of the image that's outside of the polygon area. It would allow almost any shape with any texture. Thanks for the help guys. Link to comment Share on other sites More sharing options...
hollowdoor Posted March 11, 2015 Author Share Posted March 11, 2015 As an addendum it might also be useful to use interpolation on a polygon's points to get smooth curves. Then I can use the original polygon for the physics body. Per the needs of my original question. The polygon would have to have a lot of points, and there would also be a clipping problem with the interpolated lines too. It would be worth it though. Link to comment Share on other sites More sharing options...
Recommended Posts