Object moving using enterFrame, but When touched STOPS moving : Is this a Corona SDK LIMITATION?

Hi,

I create an object using a module then I move it using enterFrame event. I then have a touch event set-up in a seperate module, and when object touched this stops all movement to object. If i use print to check if enterFrame is working properly, I find that its working fine.

I think this maybe a Corona SDK limitation, due to this: http://docs.coronalabs.com/guide/physics/limitations/index.html

********Is there a way to code this?

  1. I want to spawn object using separate module

  2. I want to have object move to the right, and continue moving after being touched.

  3. I want to be able to set up touch event in seperate module

– LEVEL SCENE

function scene1:create(event)

local floatingGround = display.newRect( centerX, 200, display.contentWidth, 20 )

physics.addBody( floatingGround, “static”, {friction = 1})

M.moduleIcon = spawnEnem.spawn({

image        = “icon.png”,

objTable     = M.lilEnemTable,

hasBody      = true,

density      = 1,

friction     = 1,

bounce       = 1,

bodyType     = “dynamic”,

})

end

function scene1:show(event)

if event.phase == “did” then

 

function gameLoop(event)

M.moveEnem ({

obj = M.moduleIcon,

})

end

 

M.moduleIcon.touch = M.touchLilEnem

M.moduleIcon:addEventListener( “touch”, M.moduleIcon )

Runtime:addEventListener( “enterFrame”, gameLoop )

end

end

– SPAWNENEM aka the OBJECT

local M = {}

M.spawn = function(parameter)

local object = display.newImage( parameter.image  , 200, 200 )

 

object.table    = parameter.objTable

object.index    = #object.table + 1

object.myName   = object.index

 

object.table[object.index] = object

 

local hasBody = parameter.hasBody

if hasBody then

object.density     = parameter.density or 0.1 

object.friction    = parameter.friction or 1

object.bounce      = parameter.bounce or 0.1

object.isSensor    = parameter.isSensor or false

object.bodyType    = parameter.bodyType or “dynamic”

object.filterTable = parameter.filterTable or nil

 

physics.addBody(object, object.bodyType, {object.density, object.friction, object.bounce, object.isSensor, filter = object.filterTable})

end

return object

end – End of spawnFunction

return M

–M aka TOUCH and MOVEMENT module

local M = {}

M.spawn = function(parameter)

local object = display.newImage( parameter.image  , 200, 200 )

 

object.table    = parameter.objTable

object.index    = #object.table + 1

object.myName   = object.index

 

object.table[object.index] = object

 

local hasBody = parameter.hasBody

if hasBody then

object.density     = parameter.density or 0.1 

object.friction    = parameter.friction or 1

object.bounce      = parameter.bounce or 0.1

object.isSensor    = parameter.isSensor or false

object.bodyType    = parameter.bodyType or “dynamic”

object.filterTable = parameter.filterTable or nil

 

physics.addBody(object, object.bodyType, {object.density, object.friction, object.bounce, object.isSensor, filter = object.filterTable})

end

return object

end – End of spawnFunction

return M

This mental block has stopped all production on my game that I’ve been working months on, if anyone can let me know if there is a solution to my problem or do I have to reconstruct my whole game…

Thank you,

-Nick

When I complete my game I plan to turn into a paying customer and launch my App. Along with dreams of completing more apps! Corona’s GUI and API is awesome, but please Corona team I need help of getting over this hurdle in order to materialize my hard work.

I doubt very much that this is a flaw in Corona’s system as developers have been creating physics objects of all sorts with many kinds of interaction for years.

It would appear that you have not posted your touchLilEnem function, which seems to get called when a touch event occurs on a spawned object, so I cannot see why your object is stopping. I imagine it’s because you’re applying a touch joint or otherwise cancelling the motion values.

Your code needs a lot of renaming and cleaning - try refactoring it to clean up the logic and you might see some reasons why things are happening.

When I complete my game I plan to turn into a paying customer and launch my App. Along with dreams of completing more apps! Corona’s GUI and API is awesome, but please Corona team I need help of getting over this hurdle in order to materialize my hard work.

I doubt very much that this is a flaw in Corona’s system as developers have been creating physics objects of all sorts with many kinds of interaction for years.

It would appear that you have not posted your touchLilEnem function, which seems to get called when a touch event occurs on a spawned object, so I cannot see why your object is stopping. I imagine it’s because you’re applying a touch joint or otherwise cancelling the motion values.

Your code needs a lot of renaming and cleaning - try refactoring it to clean up the logic and you might see some reasons why things are happening.