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
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