strange physics problem

hi guys i am just hanging with something strange physics problem it will be nice if anyone points me in right direction or solve this issue

here is the code

[lua]display.setStatusBar( display.HiddenStatusBar )
local physics = require “physics”
physics.start()
local x = -10
local y = -10
physics.setGravity(x,y)
physics.setDrawMode(“hybrid”)

local height = display.contentHeight
local width = display.contentWidth

local ground = display.newRect(0,height - 1,width,1)
physics.addBody(ground,“static”)

local ceiling = display.newRect(0,0,width,1)
physics.addBody(ceiling,“static”)

local leftWall = display.newRect(0,0,1,height)
physics.addBody(leftWall,“static”)

local rightWall = display.newRect(width - 1,0,1,height)
physics.addBody(rightWall,“static”)

local beamShape = {-75,-20,75,-20,75,-10,-75,-10}
local triShape1 = {-70,-15,-50,15,-30,-15}
local triShape2 = {70,-15,50,15,30,-15}

local img = display.newImage(“trampoline.png”)
img.x = 240
img.y = 160
physics.addBody(img,“dynamic”,
{ density=3.0, bounce=0.2, shape=beamShape },
{ density=2.0, bounce=0.31, shape=triShape1 },
{ density=2.0, bounce=0.31, shape=triShape2 })
–img.isFixedRotation = true

local function callMe()
y = y * -1
x = x * -1
physics.setGravity(x,y)
print(y)
print(“called”)
end
timer.performWithDelay(2500,callMe,0)[/lua]

see the effect after uncommenting the img.isFixedRotation = true and with commenting the same

this is my problem

u need trampoline.png from eggBraker example
Thanks in advance [import]uid: 12482 topic_id: 10722 reply_id: 310722[/import]

any one with similar problem or any solution ??? [import]uid: 12482 topic_id: 10722 reply_id: 38930[/import]

Sorry, what exactly is the problem?

I can see it bouncing about and I can see it sticking when that line is uncommented but I’m not sure what you are trying to achieve.

Can you be specific, please? :slight_smile:

Peach [import]uid: 52491 topic_id: 10722 reply_id: 38951[/import]

First off this code was crashing hard. I found that your triShape1 coordinates are incorrect and do not go clockwise. Basically you are trying to create a zigzag line and I think you were going more for a triangle. I commented out the triShape1 code and it seems to work correctly. It would rotate or wouldn’t rotate depending on whether the isFixedRotation setting was there or not. I also do not know what your original problem was. [import]uid: 31262 topic_id: 10722 reply_id: 38966[/import]

@peach :- that’s my problem when img.isFixedRotation = true img (my physics body) is bouncing but when it is false which is by default it is not bouncing and not affecting by gravity after some time i want that it should rotate and affect by some forces including gravity

@aaron :- i also think so my triShape1 coordinates are wrong as in other test some dynamic objects get out that part not for other also if there is no trishape1 then everything works fine i don’t know about clockwise order will chk it
and thanks to both

:slight_smile: [import]uid: 12482 topic_id: 10722 reply_id: 39116[/import]

yup by changing coordinates with this

local triShape1 = {-30,-15,-50,15,-70,-15}

it works fine [import]uid: 12482 topic_id: 10722 reply_id: 39117[/import]