see if this helps, basically a circle / ballon hovering over a platform connected by a joint.
The line that connects the two is redrawn based on the xpos of the circle, in the enterframe event.
[code]
display.setStatusBar( display.HiddenStatusBar )
_W = display.contentWidth
_H = display.contentHeight
local W = _W
local H = _H
_G.physics = require( “physics” )
physics.start()
physics.setGravity( 0, -9.8)
–physics.setDrawMode( “hybrid” )
local myCircle = display.newCircle( 100, 100, 30 )
local myRectangle = display.newRect(50,display.contentHeight-50, 150, 50)
myCircle:setFillColor(255,33,225)
myRectangle.strokeWidth = 3
myRectangle:setFillColor(255, 0, 0)
myRectangle:setStrokeColor(255, 0, 0)
physics.addBody( myCircle, { density=0.9, friction=0.3, bounce=0.3} )
physics.addBody( myRectangle, “static”, { friction=0.5, bounce=0.3 } )
myCircle.x = myRectangle.x; myCircle.y = myRectangle.y-150;
myCircle.x = myRectangle.x
myCircle:setReferencePoint(display.BottomCenterReferencePoint);
local myline = display.newLine(myCircle.x,myCircle.y, myRectangle.x,myRectangle.y )
myline:setColor( 255, 255, 0, 255 )
myline.width = 3
–Wheel Joint
local myJoint = physics.newJoint(“wheel”, myCircle, myRectangle, myCircle.x, myCircle.y, 1, 1)
myJoint.isMotorEnabled = false;
myJoint.motorSpeed = 0;
–Limit the distance that myCircle will travel from jointed object (currentXpos, 100px up)
myJoint.isLimitEnabled = true
myJoint:setLimits(0, 100);
local myListener = function( event )
–remove and redraw line while the Circle moves
if myline ~= nil then
myline:removeSelf()
myline = display.newLine(myCircle.x,myCircle.y, myRectangle.x,myRectangle.y )
myline:setColor( 255, 255, 0, 255 )
myline.width = 3
myCircle:toFront()
end
end
Runtime:addEventListener( “enterFrame”, myListener )
[/code] [import]uid: 11860 topic_id: 16852 reply_id: 67066[/import]