Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Beginner. Help with adding force to physics body — Gideros Forum

Beginner. Help with adding force to physics body

linker_ualinker_ua Member
edited November 2011 in User experience
I start to learn Gideros for 2 days ago. And now I have question. Hope sombody helps me :)
I have ball which fall down.. bouncing.. and stops..
I have button, on click I want to add force to this ball using some direction
I try a lot of methods which I can imagine but no one - works.... here is code:
Please, correct me to right example.. [Error message was shown when I push left button]
and sorry for my English if somthing wrong :)


firstHero = actors[1]
firstHeroBody = firstHero.body

function onClick(event)
if event:getTarget() == left then
firstHero:setLinearVelocity(240, 200)
--sprite:setRotation(firstHeroBody:getAngle() * 180 / math.pi)
--print("left")
end
end
left:addEventListener("click", onClick)
right:addEventListener("click", onClick)

local function onEnterFrame()
world:step(1/60, 8, 3)
firstHero:setPosition(firstHeroBody:getPosition())
firstHero:setRotation(firstHeroBody:getAngle() * 180 / math.pi)

end
stage:addEventListener(Event.ENTER_FRAME, onEnterFrame)

Comments

  • Yaaaahooooo!!! I have understand my problem!!!
    firstHero:setLinearVelocity(240, 200)
    need to change a physical body, because bitmap gets own XY from XY of physic body..

    firstHeroBody:setLinearVelocity(240, 200)

    Likes: atilim, gorkem

    +1 -1 (+2 / -0 )Share on Facebook
Sign In or Register to comment.