Hola
Well here is my second post for the evening:)
I am playing with the pulley joint system and trying to get it so one of my objects literally shoots up and stays put…locked tight. As a bit of background my plan is to use this as part of a grapple hook system. So the player would:
- Tap a point on screen
- A object fires out to that point…
- if it hits something that can be “grappled” it then creates the pulley joint at said position. And sets up my sprite (hero) and another object (invisible) as objects on the pulley. The invisible object will drop down pulling my dude up.
Now i’m not sure if this is the best approach so firstly… if it isn’t and someone has a better idea then im all ears:)
Below is my crude code so far (for the pulley part as i’m working in chunks to test stuff:))…what happens here kind of almost works but when my hero sprite gets to the top he twitches and flitches about vs the desired outcome of being locked tight. Any pointers on how to fix this or a better way of approaching this would be truly appreciated.
local _W = display.contentWidth;
local _H = display.contentHeight;
local physics = require (“physics”)
physics.start()
physics.setDrawMode(“hybrid”)
local anchorA_x = 100
local anchorA_y = 50
local anchorB_x = anchorA_x
local anchorB_y = anchorA_y
weight = display.newCircle(50, 50, 10)
weight:setFillColor(0,255,00)
physics.addBody( weight, { density = 2.0} )
weight.myName = “weight”
weight.isVisible = false
weight.x = 100
weight.y = anchorA_y
–crate2:applyForce( 1500, 2000, crate2.x, crate2.y )
hero = display.newCircle(50, 50, 10)
hero:setFillColor(30,255,00)
physics.addBody( hero, “dynamic”)
hero.myName = “hero”
hero.x = 300
hero.y = 200
–> Add the floor
local floor = display.newRect(0,0,_W,20);
floor:setReferencePoint(display.CenterReferencePoint)
floor.x= _W/2
floor.y= _H+floor.height/2
floor.myName = “floor”
physics.addBody(floor, “static”);
myJoint = physics.newJoint( “pulley”, weight, hero, anchorA_x,anchorA_y, anchorB_x,anchorB_y, weight.x,weight.y, hero.x,hero.y,0.2 )
cheers
ade [import]uid: 66324 topic_id: 11048 reply_id: 311048[/import]