srikarg Posted January 31, 2014 Share Posted January 31, 2014 Hello everyone, Based on this comment, I realized that Phaser removed support for GeomSprites. However, I'm thinking about making a game in which I just need simple shapes rather than image/spritesheet assets. I thought about using the Graphics object, but realized that I cannot apply physics to the shapes I create using that (as far as I know). Then, I found information about game.debug.render to create circles and rectangles, but ran into the same problem. My question: Is there a way to create a sprite that is just a simple circle, rectangle, or any other basic shape AND has physics properties (like being able to collide with other sprites, drag, etc.). I confirmed this lack of physics properties by checking out the classes for the Rectangle and Circle. Thanks in advance for any help! Link to comment Share on other sites More sharing options...
Alvin Posted January 31, 2014 Share Posted January 31, 2014 Before 1.1.4 the physics system was just an aabb system, making it impossible to work with circles or rotated rectangles. In 1.1.4 Richard integrated a brand-new SAT system which enables us to work with physics bodies that are circles, rectangles, or any kind of polygon, and also offers the ability to rotate the bodies. (This is awesome, he's been working on it for weeks now It's not released yet, but it's very close, have a look at the examples in the dev branch,so you know what's available and you'll perhaps find a workaround using a coloured square and a mask. jerome and srikarg 2 Link to comment Share on other sites More sharing options...
srikarg Posted January 31, 2014 Author Share Posted January 31, 2014 Thanks for replying Alvin! I guess I'll check the dev branch for the new collision system then. Can't wait for the release! P.S.: Thanks for working on it Richard! Link to comment Share on other sites More sharing options...
jerome Posted February 1, 2014 Share Posted February 1, 2014 I just gave a read at the new PhysicsArcade.js Richard coded in the 1.1.4Huge work ! So, as far as I understand, you'll soon be able to still create a sprite, then attach it a body. Indenpently the sprite image shape, this body can be a rectangle, a circle or a (convex) polygon.Because Phaser now (as 1.1.4) uses the SAT.js lib, body physics and collisions will be computed on these new shape possibilties. So you'll easily rotate rectangular, polygonal or circular sprites and collide them.This is really a big jump ahead in the framework capabilities : colliding only two rectangular rotating sprites was some lack until now... I'll review my french article soon SAT theorem can't compute collisions on non convex polygons. Non convex polygons are to be divided in many convex polygons or another algorithm is to be used (infinite point, etc). Those both methods require extra CPU cost and time. But I guess there is already so much to do with polygon/circle collisions, we will enjoy this new framework capability ! I think if we choose some polygon body the SAT will be selected and if we choose some rectangle body, the good old AABB wil be selected so as some games don't require rotations. Some kind of optimization ... Not read about it, but I guess it is the way to do. Waiting for the new API docs and examples. Link to comment Share on other sites More sharing options...
Teemu-Tor Posted February 7, 2014 Share Posted February 7, 2014 Hi, Does polygon (or geometry) have to be attached to a sprite? Or is there any other way to do it?Ideally I would like to create a layer which contains all the polygons - is this possible? -Teemu Link to comment Share on other sites More sharing options...
rich Posted February 7, 2014 Share Posted February 7, 2014 It doesn't have to be attached to a Sprite, no. You could create a SAT.Polygon and check for collision with SAT.Response(yourPoly, yourSprite.body.polygon) jerome 1 Link to comment Share on other sites More sharing options...
Teemu-Tor Posted February 8, 2014 Share Posted February 8, 2014 Ok, gotta test that. Thanks for the quick answer. Link to comment Share on other sites More sharing options...
Teemu-Tor Posted February 10, 2014 Share Posted February 10, 2014 What am I doing wrong? Because it seems that i cant get the collision detection working... 1. when the player first hits the obstacle polygon - collision detection works ok2. when player wiggles about a bit - collision detection somehow fails and lets player aabb collision box straight thru ps. tried with different polygons and geometries - same result, except with circle when player object jumped all over the place and registered false collisions. Any thoughts? Link to comment Share on other sites More sharing options...
Teemu-Tor Posted February 14, 2014 Share Posted February 14, 2014 Fixed by 1.15! Thanks! Link to comment Share on other sites More sharing options...
srikarg Posted March 11, 2014 Author Share Posted March 11, 2014 Can anyone please link to any documentation on creating basic shapes in Phaser 1.15? I tried searching, but all I've come up with is the SAT.js library that's bundled with the new version of Phaser. Is this the library I use for the shapes? Or is there a wrapper for simple geometric shapes in Phaser? Link to comment Share on other sites More sharing options...
srikarg Posted August 26, 2014 Author Share Posted August 26, 2014 Any replies for this ^? I need it for a game that I'm working on... Link to comment Share on other sites More sharing options...
wayfinder Posted August 27, 2014 Share Posted August 27, 2014 Check out the documentation for p2 physics! Link to comment Share on other sites More sharing options...
tidelake Posted April 4, 2016 Share Posted April 4, 2016 On 2/6/2014 at 7:03 PM, rich said: It doesn't have to be attached to a Sprite, no. You could create a SAT.Polygon and check for collision with SAT.Response(yourPoly, yourSprite.body.polygon) Hi, I think I'm trying to do something similar. Create a pinball-style paddle which can change colors during the game. I appreciate any help. I'm a total newbie. I'll look for examples using SAT. Thank you. Link to comment Share on other sites More sharing options...
Recommended Posts