Spawn is not responsive on device

In my drop game my spawnController function is working perfectly on the corona simulator but when Im checkin it on my device it is not responsive at all. the objects fall without any connection to the spawnTimer(always late than it should but not at the same rate).

any idea what causes the problem? thanks in advance.

Can you share the related part of the code so we can see what’s going on?

local function spawnController( action )

    if ( spawnTimer and ( action == “start” or action == “stop” ) ) then

        timer.cancel( spawnTimer );

    end

    if( action == “start” ) then

        local spawnTime = 250;

        spawnTimer = timer.performWithDelay( spawnTime, function( e )

            spawnWater();

            if( e.count % ( 9 * ( 1000 / spawnTime ) ) == 0 ) then

               spawnHeart();    

           end   

            if( e.count % ( 7 * ( 1000 / spawnTime ) ) == 0 ) then

                spawnCoin();    

            end   

        end, 0 );

    elseif ( action == “pause” ) then

        timer.pause( spawnTimer )

    elseif ( action == “resume” ) then

        timer.resume( spawnTimer )

    end

end

only the drops( water ) not spawning as it should on device only. worked fine till I added some transitions and effects to game.lua scene but those cancel before spawnController function starts… maybe it’s somthing to do with the memory of the device against the pc’s.

I dunno if theres more code related exept this one if you can tell me which part of my code do you want me to paste for you to understard better my problem ill be happy to do that… thanks for help

For future posts, please format your code with the “<>” icon. That makes the code more readable.

There is no reference to a transition in the code you submitted so I’m going to ignore it this time. If you want, please submit the whole code with transitions in it.

I took the liberty of simplfying things a little. Hope you don’t mind. If you have anything to add to your code, I’ll take a look at the updated version but before you go, can you check the code below to see if it fits your need?

local function spawnWater() &nbsp;&nbsp; &nbsp;print "water" end local function spawnHeart() &nbsp;&nbsp; &nbsp;print "heart" end local function spawnCoin() &nbsp;&nbsp; &nbsp;print "coin" end local function spawnController( action ) &nbsp;&nbsp;&nbsp; if ( spawnTimer and ( action == "start" or action == "stop" ) ) then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; timer.cancel( spawnTimer ); &nbsp;&nbsp;&nbsp; end &nbsp; &nbsp;&nbsp;&nbsp; if( action == "start" ) then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; local spawnTime = 250; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; spawnTimer = timer.performWithDelay( spawnTime, function( e ) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;print ("count", e.count) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; spawnWater(); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if( e.count % 36 == 0 ) then -- i removed calculations because result was always 4 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; spawnHeart(); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if( e.count % 28 == 0 ) then -- i removed calculations because result was always 4 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; spawnCoin(); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end, 0 ); &nbsp; &nbsp;&nbsp;&nbsp; elseif ( action == "pause" ) then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; timer.pause( spawnTimer ) &nbsp; &nbsp;&nbsp;&nbsp; elseif ( action == "resume" ) then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; timer.resume( spawnTimer ) &nbsp;&nbsp;&nbsp; end end spawnController("start")

Please ignore the code above. Can you hook me up with a sample project with the full code that’s buggy and the assets related to it?

Can you share the related part of the code so we can see what’s going on?

local function spawnController( action )

    if ( spawnTimer and ( action == “start” or action == “stop” ) ) then

        timer.cancel( spawnTimer );

    end

    if( action == “start” ) then

        local spawnTime = 250;

        spawnTimer = timer.performWithDelay( spawnTime, function( e )

            spawnWater();

            if( e.count % ( 9 * ( 1000 / spawnTime ) ) == 0 ) then

               spawnHeart();    

           end   

            if( e.count % ( 7 * ( 1000 / spawnTime ) ) == 0 ) then

                spawnCoin();    

            end   

        end, 0 );

    elseif ( action == “pause” ) then

        timer.pause( spawnTimer )

    elseif ( action == “resume” ) then

        timer.resume( spawnTimer )

    end

end

only the drops( water ) not spawning as it should on device only. worked fine till I added some transitions and effects to game.lua scene but those cancel before spawnController function starts… maybe it’s somthing to do with the memory of the device against the pc’s.

I dunno if theres more code related exept this one if you can tell me which part of my code do you want me to paste for you to understard better my problem ill be happy to do that… thanks for help

For future posts, please format your code with the “<>” icon. That makes the code more readable.

There is no reference to a transition in the code you submitted so I’m going to ignore it this time. If you want, please submit the whole code with transitions in it.

I took the liberty of simplfying things a little. Hope you don’t mind. If you have anything to add to your code, I’ll take a look at the updated version but before you go, can you check the code below to see if it fits your need?

local function spawnWater() &nbsp;&nbsp; &nbsp;print "water" end local function spawnHeart() &nbsp;&nbsp; &nbsp;print "heart" end local function spawnCoin() &nbsp;&nbsp; &nbsp;print "coin" end local function spawnController( action ) &nbsp;&nbsp;&nbsp; if ( spawnTimer and ( action == "start" or action == "stop" ) ) then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; timer.cancel( spawnTimer ); &nbsp;&nbsp;&nbsp; end &nbsp; &nbsp;&nbsp;&nbsp; if( action == "start" ) then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; local spawnTime = 250; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; spawnTimer = timer.performWithDelay( spawnTime, function( e ) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;print ("count", e.count) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; spawnWater(); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if( e.count % 36 == 0 ) then -- i removed calculations because result was always 4 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; spawnHeart(); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if( e.count % 28 == 0 ) then -- i removed calculations because result was always 4 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; spawnCoin(); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end, 0 ); &nbsp; &nbsp;&nbsp;&nbsp; elseif ( action == "pause" ) then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; timer.pause( spawnTimer ) &nbsp; &nbsp;&nbsp;&nbsp; elseif ( action == "resume" ) then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; timer.resume( spawnTimer ) &nbsp;&nbsp;&nbsp; end end spawnController("start")

Please ignore the code above. Can you hook me up with a sample project with the full code that’s buggy and the assets related to it?