Hi guys,
I am currently developing an app in Corona and came across a problem, I have no idea how to solve. I need to make an animation from a certain point towards an object, for better understanding, the animation is a rope and the object a player. When he jumps, I need an animated rope from the ceiling… I tried runtime and update the position on the rope, but then I have to add a rotation and it gets complicated… Would anyone offer me a better solution or maybe a tutorial I don’t know about…
Thanks in advance
-- Consider this (totally made up example) (May have typos; only tested in my head) -- local cx = display.contentCenterX local cy = display.contentCenterY local anchorX = cx local anchorX = cy - 200 local player = display.newCircle( cx - 100, cy + 100, 20 ) function player.swingRight( self, time ) transition.to( self, { x = cx + 100, onComplete = self.swingLeft, time = time or 2000} ) end function player.swingLeft( self, time ) transition.to( self, { x = cx - 100, onComplete = self.swingRight, time = time or 2000} ) end function player.enterFrame( self ) display.remove(self.myRope) self.myRope = display.newLine( anchorX, anchorY, self.x, self.y ) end player:swingRight( 1000 )
Note: In this example, the ‘rope’ stretches. You can achieve a ‘swinging about and axis’ behavior by introducing physics and joints.
-- Consider this (totally made up example) (May have typos; only tested in my head) -- local cx = display.contentCenterX local cy = display.contentCenterY local anchorX = cx local anchorX = cy - 200 local player = display.newCircle( cx - 100, cy + 100, 20 ) function player.swingRight( self, time ) transition.to( self, { x = cx + 100, onComplete = self.swingLeft, time = time or 2000} ) end function player.swingLeft( self, time ) transition.to( self, { x = cx - 100, onComplete = self.swingRight, time = time or 2000} ) end function player.enterFrame( self ) display.remove(self.myRope) self.myRope = display.newLine( anchorX, anchorY, self.x, self.y ) end player:swingRight( 1000 )
Note: In this example, the ‘rope’ stretches. You can achieve a ‘swinging about and axis’ behavior by introducing physics and joints.