Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Catapult with Box2D — Gideros Forum

Catapult with Box2D

ktcktc Member
edited October 2012 in General questions
I am looking for a simple catapult/canon example that uses Box2D. Is there any simple example I can learn from?

Comments

  • ktcktc Member
    @ar2rsawseen additional question. How can I make the cannons path visible. In other words cannon will leave its travel path in the screen.
  • Well for example you have a Texture called dot (which represents one dot of path), then you can set up some kind of counter inside init function
    self.cnt = 0
    And then check inside onEnterFrame function if counter reached some point, for example value 10, take current body's position and place a dot there.
    self.cnt = self.cnt + 1
    if self.cnt == 10 then
        self.cnt = 0
        local x, y = self.ball.body:getPosition()
        local dotImg = Bitmap.new(dot)
        dotImg:setAnchorPoint(0.5, 0.5)
        dotImg:setPosition(x, y)
        self:addChild(dotImg)
    end
    Something like that
Sign In or Register to comment.