Originally, I had an image of a windmill and an image of a windmill blade. I started by adding 4 blades and setting their rotation, then setting their reference point, and then rotating them around a circle in the center of my windmill. That worked great! Then I added physics and it all fell to pieces as the physical location of the physics object wasn’t in the place that the rotation was. Basically my golf ball wouldn’t bounce off the blades. on IRC someone named Goosh suggested using 2 squares and having them overlap in the center, but that doesn’t work for me for a very good reason. I plan on blowing up individual blades, and the center will then change.
Here’s what I’ve got. I can’t get the windmill blades to spin, I have no idea what I’m doing wrong. I can’t find a single example on how to do this using corona. Simplest example possible (assume all variables are declared if I left out a local here or there)
myCircle = display.newCircle(screenW / 2, 132 , 10) physics.addBody(myCircle, "kinematic", {friction=0.1, radius=10}) local blade = display.newImage("windmill\_blade.png") blade.x = screenW / 2 - imageWidth / 2 blade.y = 130 physics.addBody(blade, "kinematic", {friction=0.1, density=0.8}) local joint = physics.newJoint( "pivot", blade, myCircle, 132, 130)
I have tried these:
blade:applyTorque(5000) -- and many other numbers myCircle:applyTorque(5000) -- and many other numbers joint:applyTorque(5000) -- this blows up?
I’m just not sure what I’m doing wrong. I’ve tried weld joints, I’ve tried static bodies, I’ve tried dynamic bodies, although I don’t want them affected by gravity, nor do I want them to move when the golf ball hits them. I’ve got no friggin idea what the right way to do this is, and in the examples I see nothing related to this.
Making both the blade and the circle dynamic made some really interesting things happen, but not quite what i was looking for as I don’t want the ball to move (it’s just an anchor)