Hi,
I have a physic object which will keep on swinging left right like a pendulum.
I want to attach a small physic object (as a physic sensor) at the tip of the pendulum.
No matter how I move or drag or swing the pendulum, the small physic object will stick at the tip as a sensor to sense collision with other object and trigger a function.
Here is my code:
local arrow = display.newImage(‘arrow.png’)
arrow.anchorX = 0.5
arrow.anchorY = 0.20
arrow.x = display.contentWidth / 2
arrow.y = 25
arrow.rotation = 0
arrow.status = “rotate”
physics.addBody(arrow, “static”)
arrow.collision = onCollision
slowDown = 0
local hotSpot = display.newCircle(100,100,5)
physics.addBody(hotSpot, “static”)
hotSpot:setFillColor(0,0,0)
hotSpot.anchorX = 0.5
hotSpot.anchorY = 0
physics.newJoint( “pivot”, arrow, hotSpot, 1, 1)
It doesn’t work. The hotSpot will only stick to the center of the arrow.