stopping a runtime

this is the way i had to setup the runtime

function bg:start()  
 Runtime:addEventListener( "enterFrame", function()  
 move( self, params ) end )  
 end  

so i could pass some params to the function
how do i get it to remove

i tried

function bg:pause()  
 Runtime:removeEventListener( "enterFrame", function()  
 move( self, params ) end )  
 end  

but it doesn’t work
any other suggestions [import]uid: 7911 topic_id: 21191 reply_id: 321191[/import]

for my game, i used the method with flags
for example

[lua]function pause( )
gamePause = true
end

function start( )
gamePause = false
end

function enterFrame( )
if not gamePause then
– blah blah blah
end
end[/lua] [import]uid: 114118 topic_id: 21191 reply_id: 83933[/import]

thanks but that wont work for what i need im not trying to pause something ( i know i used pause in the function name ) what i need is the runtime removed [import]uid: 7911 topic_id: 21191 reply_id: 84105[/import]

Try assigning the function to a variable and then remove it.

[lua]local eventFunc = function() print(‘do domething’) end

Runtime:addEventListener('enterFrame’eventFunc)[/lua]

then later on

[lua]Runtime:removeEventListener(‘enterFrame’,eventFunc)[/lua]

This issue is that you’re losing scope of the function, preventing you from removing it. [import]uid: 49520 topic_id: 21191 reply_id: 84108[/import]

i dont think that will work either
what im doing is i have a class where i can do this

img = aura.newImage({pic.png})

then
img:up(4)
img:start()

the img:start() function calls the method posted above which
starts the movement where i problem comes in at is when i try to release the memory by removing img the runtime kicks out an error cause its not removed first [import]uid: 7911 topic_id: 21191 reply_id: 84110[/import]

can you post your code? [import]uid: 49520 topic_id: 21191 reply_id: 84111[/import]

sorry cant post code at this stage but can show structure of code

aura = {]  
  
aura.newImage = function(arg)  
 img = {}  
 img = display.newImage( arg )  
 img:move( arg1, arg2 )  
 img:up(arg1)  
 img:down(arg1)  
 img:clean()  
 img:start()  
 return img  
  

i need the runtime to be tide to the img this way each img returned has its own runtime

example of how this works

aura = require( "aura" ) -- requires the module  
image1 = aura.newImage( {"pic1.png"} ) -- creates the image  
image2 = aura.newImage( {"pic2.png"} ) -- a second image  
image1:up(4) -- sets the direction and speed to move  
image2:down(7) -- direction and speed of second image  
image1:start() -- starts image1 animation  
  
--then when done using image1 i can   
  
image1:clean() --removes images from memory  
image2:start() -- starts image2 animation   

but the code kicks out an error cause the runtime from image1 is still there
the code in OP bg:start() is code in img:start() above
code in OP bg:pause() is img:clean() above but without the image remove code in it
hope this helps you picture the flow of the code [import]uid: 7911 topic_id: 21191 reply_id: 84112[/import]

what is you event supposed to do?
and why on enterfarme event? [import]uid: 49520 topic_id: 21191 reply_id: 84115[/import]

email me
jstrahan73
at
g m a i l [import]uid: 7911 topic_id: 21191 reply_id: 84116[/import]

email sent [import]uid: 49520 topic_id: 21191 reply_id: 84126[/import]