Hello, here a simple problem:
Using the Transition Manager (I want to pause later all transitions) I'm moving an object from left to right - after collison I remove it - but it's not deleted complete - why?
physics = require("physics")
tm = require("transitionManager")
tm = tm.new()
physics.start(); physics.setGravity( 0, 0 ) ; physics.setScale( 60 ) ; --physics.setDrawMode( "hybrid" )
local stop_right = display.newImageRect( "grafik/brick1.png", 140,768 )
physics.addBody( stop_right, "dynamic", { density=0.0, friction=0, bounce=0.0 } )
stop_right.myName = "Right";
stop_right.x = 1094; stop_right.y = 384
stop_right.isFixedRotation = true ; stop_right.isSensor = true
local myGroup = display.newGroup()
function mem_check()
collectgarbage()
print( "\nMemUsage: " .. collectgarbage("count") )
local textMem = system.getInfo( "textureMemoryUsed" ) / 1000000
print( "TexMem: " .. textMem )
end
function create_shoot_03( pos_x,pos_y)
local size = math.random(10,50)
local shoot = display.newImageRect( "grafik/ammo_02.png",size,size)
shoot.myName = "Shoot"
physics.addBody( shoot, "dynamic", { density=0.0, friction=0, bounce=0.0, radius=size/2.5} )
shoot.isSensor = true
shoot.x = pos_x
shoot.y = pos_y
myGroup:insert( shoot )
local speed_x = 0.05
tm:add( shoot, { time=1500, x=1100} )
-- ################################################################# --
function onCollision(self, event )
if ( shoot and event.phase == "began") then
if (event.other.myName=="Right") then
speed_x = nil; size = nil ; shoot.myName = nil ;
shoot.power = nil ; pos_x = nil ; pos_y = nil ; n = nil
if ( shoot ) then
display.remove( shoot ) ;
shoot:removeEventListener( "collision", shoot ) ;
shoot = nil
end
collectgarbage("collect")
mem_check()
end
end
end
shoot.collision = onCollision
shoot:addEventListener( "collision", shoot )
end
mem_check()
create_shoot_03( 0,384)