Hello everyone,
I am having an issue with my project I am working on. On my project I have objects going upward ( using, physics.setGravity(0, -0.3), a negative y-direction gravity value ). This works fine, as expected. But the problem arises when I try to create - spawn - other bodies downwards ( positive y-direction gravity value ). Is there a way I can get this accomplished? I have tried to set the gravity inside each spawn function with different y-direction gravity values, but I am only getting objects going up and no objects coming down.
Here are the functions I mentioned above:
local objectUpWard = function()
physics.setGravity(0, -0.4) -- upward gravity
local temp3 = math.random(1,#carTableName)
local object = display.newImageRect(carTableName[temp3] .. ".png", 45,90)
--carLane1.rotation = 180
object.yScale = 0.8
object.xScale = 0.7
object.x = \_W \*0.5 - 57
object.y = \_H + 134
physics.addBody(object, {density=1.2, bounce = 0, radius = 5})
object.hit = "obj"
object.myName = "obj"
end
And the downward function:
local objectDownWard = function()
physics.setGravity(0, -0.4) -- upward gravity
local temp4 = math.random(1,#carTableName)
local object1 = display.newImageRect(carTableName[temp3] .. ".png", 45,90)
--carLane1.rotation = 180
object1.yScale = 0.8
object1.xScale = 0.7
object1.x = \_W \*0.5 - 57
object1.y = \_H + 134
physics.addBody(object1, {density=1.2, bounce = 0, radius = 5})
object1.hit = "obj1"
object1.myName = "obj1"
end
Your help is highly appreciated!
Thank you. [import]uid: 75258 topic_id: 22416 reply_id: 322416[/import]