Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Can I Create a body do not stop hero moving? — Gideros Forum

Can I Create a body do not stop hero moving?

albert988albert988 Member
edited April 2013 in General questions
The situation is there is a hero moving from left to right,there is a coin object which is created a body with box2d

the code is :

function Level:createObject(object)
object.body = self.world:createBody {type = b2.STATIC_BODY, fixedRotation = true, position={x=object.x, y=object.y}}
object.body.name = object.name
object.body.type = object.type
if self.map:getProperty(object, "score") ~= nil then
object.body.score = self.map:getProperty(object, "score")
end

local shape

if object.polyline then
shape = b2.ChainShape.new()
shape:createChain(unpack(self:getVertices(object.polyline)))
elseif object.polygon then
shape = b2.PolygonShape.new()
shape:set(unpack(self:getVertices(object.polygon)))
else
shape = b2.PolygonShape.new()
--shape:setAsBox(32,32,32,32,0)
local hx = object.width / 2
local hy = object.height / 2
shape:setAsBox(hx, hy, hx, hy, 0)
end

object.body:createFixture {shape = shape, density = 1, restitution = 0.2, friction = 0.3}
end

however,the coin object will stop the hero moving .
Is there a method that create body won't stop the hero moving?
I want the hero move right through the coin object and get the score.

Comments

  • fxonefxone Member
    edited April 2013
    @albert988
    in 'create fixture' put 'isSensor=true"

    like for example
    object.body:createFixture {shape = shape, isSensor=true}
Sign In or Register to comment.