How do make it where Corona ignores transparent pixels when detecting colliosions? Right now I’m trying to import an oval shaped image. The background of the oval is transparent (as in gray and white checkerboard when opened in paint.net) but corona is still intrepeting this background as part of the object. How can I prevent this? Otherwise all objects have to be rectangles and squares…
If you’re using physics based collisions, there are three ways to define the bodies shape:
-
Rectangle – uses the object’s width and height including any transparent areas.
-
Circle – you specify a radius of the circular physics body. It can be smaller or larger than the object!
-
Shape – you can define a custom shape or multiple shapes for complex bodies. the rules are no more than 8 points, no concave shapes, and the points have to be defined in clock-wise order. You deal with concave areas with multiple bodies.
If you have an oval, you would do a shape that would be kind of a stretched octagon. See:
http://docs.coronalabs.com/guide/physics/physicsBodies/index.html
Rob
Don’t forget, you can see the physics bodies too:
http://docs.coronalabs.com/daily/api/library/physics/setDrawMode.html
physics.setDrawMode( "hybrid" )
This will show you the image and its body so you can see what is going on with collisions.
You should also check out this article. You may be able to use the technique outlined here to generate a fitting body for your shape: http://coronalabs.com/blog/2014/01/28/tutorial-create-physics-bodies-from-texture-assets/
If you’re using physics based collisions, there are three ways to define the bodies shape:
-
Rectangle – uses the object’s width and height including any transparent areas.
-
Circle – you specify a radius of the circular physics body. It can be smaller or larger than the object!
-
Shape – you can define a custom shape or multiple shapes for complex bodies. the rules are no more than 8 points, no concave shapes, and the points have to be defined in clock-wise order. You deal with concave areas with multiple bodies.
If you have an oval, you would do a shape that would be kind of a stretched octagon. See:
http://docs.coronalabs.com/guide/physics/physicsBodies/index.html
Rob
Don’t forget, you can see the physics bodies too:
http://docs.coronalabs.com/daily/api/library/physics/setDrawMode.html
physics.setDrawMode( "hybrid" )
This will show you the image and its body so you can see what is going on with collisions.
You should also check out this article. You may be able to use the technique outlined here to generate a fitting body for your shape: http://coronalabs.com/blog/2014/01/28/tutorial-create-physics-bodies-from-texture-assets/