Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
gideros player crashed — Gideros Forum

gideros player crashed

alexzhengalexzheng Guru
edited December 2011 in General questions
this is my function

world is a b2world image is a sprite

function createBodyFromImage(world, image, bodyDef, ...)

local fd = {}
local dDef = {}

if bodyDef then
dDef = bodyDef
end

if dDef.type == nil then dDef.type = b2.DYNAMIC_BODY end
if dDef.position == nil then dDef.position = {x = image:getX(), y = image:getY()} end

--print(dDef.position.x)
local body = world:createBody(dDef)

if arg.n > 0 then
fd = arg[1]
end

if fd.shap == nil then

print(fd.shap )
local shape = b2.PolygonShape.new()
shape:setAsBox(image:getWidth()/2, image:getHeight()/2)
fd.shap = shap


--[[
local shape = b2.PolygonShape.new()
shape:setAsBox(40, 40)
body:createFixture{shape = shape, density = 1, restitution = 0.2, friction = 0.3}
]]
end

if fd.density == nil then fd.density = 1 end
if fd.restitution == nil then fd.restitution = 0.2 end
if fd.friction == nil then fd.friction = 0.3 end

body:createFixture(fd) -----this line make the player crashed

image.body = body

b2Sprites[#b2Sprites + 1] = image

end

Comments

Sign In or Register to comment.