i have an object ( player ) and i want to create 4 other objects ( triangles left,right,up,down ) and attach those triangles to my player so i can use t hose to move that player by touching them . but i want those triangles to move with the player …
i move the player using setLinearVelocity , i accomplish to attach them using distacnce joint and it works as i want . but the problem is when the player stop moving ( example hit a static object ) the triangles kept going in the same direction
playerHappy=display.newImageRect( "images/player1.png", CELL\_WIDTH-2, CELL\_HEIGHT-2 ) playerHappy.x=grid[24].x playerHappy.y=grid[24].y physics.addBody( playerHappy, "dynamic", { outline=PlayerHappyimageOutline, friction=100.0, density=100.0 , bounce=0.0 } ) playerHappy.isFixedRotation = true sceneGroup:insert(playerHappy) local ArrowRight = display.newImageRect("images/ArrowRight.png", CELL\_WIDTH-2, CELL\_HEIGHT-2) ArrowRight.x=playerHappy.x+playerHappy.width ArrowRight.y=playerHappy.y physics.addBody( ArrowRight, "kinematic", { outline=PlayerHappyimageOutline, friction=100.0, density=100.0 , bounce=0.0 } ) local distanceJoint = physics.newJoint( "distance", playerHappy, ArrowRight, playerHappy.x, playerHappy.y, ArrowRight.x, ArrowRight.y )