Sean, I think you should use a multi-element body here. You can read about them at https://docs.coronalabs.com/api/library/physics/addBody.html#multi-element-body.
Here’s a rough example of what you could do.
physics.addBody( player1, "dynamic", { friction=0.2, bounce=0.4, shape={0,-76,8,-68,0,-60,-8,-68} }, { friction=0.2, bounce=0.4, shape={50,34,58,26,66,34,58,42} }, { friction=0.2, bounce=0.4, shape={-50,34,-58,26,-66,34,-58,42} } )
If you replace your current physics body for the player with that, you should see that each of your characters now has a physics shape. You would need to refine the shape further though.
I am not certain if you can use circular shapes in multi-element objects, but you could also consider creating three separate characters and then using joints to weld the characters together. More on joints at https://docs.coronalabs.com/guide/physics/physicsJoints/index.html.
Thanks for the project, but I think you missed my point.
-
I’m not sure why you put your code in a scene.
-
You didn’t bother to manage your indentations etc, so the code is hard to read. I stopped after a few lines.
Whatever the case, you’re doing this wrong You can’t use the outline feature to make a consistent body (or I suspect you want three bodies) from an image like that.
A. It only works with single images surrounded by transparency. You have three circles each by themselves. Just won’t work.
B. It only approximates the best body it can. You’ll get a much better body by making your own. In this case, the multi-body suggestion above is spot on.
In the future, please remember when folks ask for code/samples your job is to make it drop-dead easy for them to read and examine your code. Nobody wants to dig through a scene when all the code could have been nicely formatted in main.lua (which is was I expected).
For your reference this is a good starter project example that I use for the basis of my answers to forums posts:
https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/askEdStarter.zip
My answers (>400 full code answers by now): https://github.com/roaminggamer/RG_FreeStuff/tree/master/AskEd
If I seem like I’m being harsh, please don’t take it that way.
You are very welcome here and I appreciate the effort you put into the example. I just want to get a little more next time you ask for help. My time is ever-more precious, but I want to help when possible.
Cheers and happy developing!
Why make a picture of these circles when you can just make them with code?
local circle = display.newCircle(100, 100, 20)
Then just add physics bodies to each individual circle with physics.addBody, no outline needed.
Hello guys, thank you for spending time to help me. I appreciate all of your answers. I know I could just make the circles and bodies separately, but for what I need it to do, it is easier for me to just make it a single image. I have some other methods and ideas in mind that will probably make it work. What roaminggamer pointed out is exactly what I needed to know.
Sorry about my coding if you could not figure out what was going on. I am just a noob
A. It only works with single images surrounded by transparency. You have three circles each by themselves. Just won’t work.
B. It only approximates the best body it can. You’ll get a much better body by making your own. In this case, the multi-body suggestion above is spot on.
The biggest issue with this is that Corona’s built-in circles look like they were drawn on a ZX81…
[quote=“Blex,post:25,topic:348225”]
Why make a picture of these circles when you can just make them with code?
local circle = display.newCircle(100, 100, 20)
Then just add physics bodies to each individual circle with physics.addBody, no outline needed. [/quote]
Yeah, that’s true…