I’ve searched high and low for a way to get the zero alpha of a png to not register as part of the object’s physical boundaries, but am unable to find anything mentioning this. All object collision seems to want to use natively drawn basic shapes, but I’d much rather just draw an object and paste it in, not having to worry about the rectangular boundaries of the png. Is there a way to do this? Or will I have to manually trace the image’s approximate boundaries using .newLine and use that as a sort of template with the two objects superimposed on each other? [import]uid: 183347 topic_id: 32694 reply_id: 332694[/import]
Try Physicseditor - the fastest way to generate “maps” for your sprites.
Joakim [import]uid: 81188 topic_id: 32694 reply_id: 129973[/import]
Try Physicseditor - the fastest way to generate “maps” for your sprites.
Joakim [import]uid: 81188 topic_id: 32694 reply_id: 129973[/import]
What Joakim said…
But on a “why does it happen” answer, Corona Physics has 3 ways of dealing with display objects and collisions.
-
use the physical boundaries of the object. This catches any transparent areas in the rectangular objects.
-
use a circle. When you create a physics object, you can change the shape to a circle with a defined radius (or diameter, I don’t remember which). This can give a better collision model, though it’s still not perfect.
-
use a custom shape. You can define a polygon’s vertices relative to the center point of the graphic that is a pretty exact shape under a couple of rules. I think it’s limited to 8 points and none of them can create a concave shape. Corona allows a physics object to be made up of multiple shapes, so you can get pretty accurate models, but it takes time to map out all of these points and to try and calculate their offsets is highly annoying.
This is why Joakim’s suggestion is nice because you load in your ping, draw the bounderies that you want for your shape (more than 8, concave shapes, etc.) and Physics editor calculates the complex shapes and spews out the Lua code for you.
I did a game that involved moving a car through a set of city streets in a top down map fashion. I used Phyiscs Editor to define all my curbs and areas the car could not drive to. [import]uid: 19626 topic_id: 32694 reply_id: 129995[/import]
What Joakim said…
But on a “why does it happen” answer, Corona Physics has 3 ways of dealing with display objects and collisions.
-
use the physical boundaries of the object. This catches any transparent areas in the rectangular objects.
-
use a circle. When you create a physics object, you can change the shape to a circle with a defined radius (or diameter, I don’t remember which). This can give a better collision model, though it’s still not perfect.
-
use a custom shape. You can define a polygon’s vertices relative to the center point of the graphic that is a pretty exact shape under a couple of rules. I think it’s limited to 8 points and none of them can create a concave shape. Corona allows a physics object to be made up of multiple shapes, so you can get pretty accurate models, but it takes time to map out all of these points and to try and calculate their offsets is highly annoying.
This is why Joakim’s suggestion is nice because you load in your ping, draw the bounderies that you want for your shape (more than 8, concave shapes, etc.) and Physics editor calculates the complex shapes and spews out the Lua code for you.
I did a game that involved moving a car through a set of city streets in a top down map fashion. I used Phyiscs Editor to define all my curbs and areas the car could not drive to. [import]uid: 19626 topic_id: 32694 reply_id: 129995[/import]