Hi again I'm encountering this strange problem what happen is I have these two platforms moving horizontally the screen in portrait right. What happens after I think about 3 minutes the platforms would lag a lot and then corona simulator would stop responding what could this be here the code that I did it with.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | local physics = require "physics" physics.start() local recycle local transit local stage = display.newRect(100, 100, 100 ,100) stage.x = 160 stage.y = 400 physics.addBody(stage ,"static",{ density = 1.5, friction = 12.0, bounce = 0.0 }) local ball = display.newCircle(10,10,10,10) ball.x = 160 ball.y = 240 physics.addBody(ball, { density = 1.5, friction = 0.0, bounce = 0.1 }) local paddle = display.newRect(0,500,100,20) paddle.y = 480 paddle.x0 = 500 physics.addBody(paddle, "static" ) local paddle2 = display.newRect(0,500,100,20) paddle2.y = 500 paddle2.x0 = 480 physics.addBody(paddle2, "static" ) function transit() transition.to(paddle, {time=2000 , x = 400 - 600, onComplete= recycle}) transition.to(paddle2, {time=2000, x = 480 - 600, onComplete= recycle}) end function recycle() paddle.x = paddle.x0 paddle.y = 50 + math.random( 320 ) paddle2.x = paddle2.x0 paddle2.y = 50 + math.random( 320 ) transit() end local onTouch = function(event) if ball.canJump then ball:applyLinearImpulse(0, -5, ball.x, ball.y) end end Runtime:addEventListener("tap", onTouch) local function onCollision(self, event ) if ( event.phase == "began" ) then if event.other.stage then ball.canJump = true end elseif ( event.phase == "ended" ) then if event.other.stage then ball.canJump = false end end end ball.collision = onCollision ball:addEventListener( "collision", ball ) transit() |
What does memory profiling tell you?
@thomas6 what do you mean memory profilling?
@thomas6 what do you mean memory profilling?
sorry for double post
You are probably getting out of memory.
Suggestion is to put the simple code below, which is provided by Ansca, into your main.lua and check the terminal for the progression of memory usage during your game until it crashes
1 2 3 4 5 6 7 8 9 10 11 | --Uncomment to monitor app's lua memory/texture memory usage in terminal... local function garbagePrinting() collectgarbage("collect") local memUsage_str = string.format( "memUsage = %.3f KB", collectgarbage( "count" ) ) print( memUsage_str ) local texMemUsage_str = system.getInfo( "textureMemoryUsed" ) texMemUsage_str = texMemUsage_str/1000 texMemUsage_str = string.format( "texMemUsage = %.3f MB", texMemUsage_str ) print( texMemUsage_str ) end |
@Raom_games this is what I would get in the terminal
Corona Terminal: line 9: 11418 Terminated "$path/Corona Simulator.app/Contents/MacOS/Corona Simulator" $*
logout
any ideas?
two questions:
1)is line 9 from your main.lua file the same you posted in your first message (that is 'stage.y = 400')? In fact your output says that the crash happens because something went wrong in line 9 of your main.lua
2) are the numbers of memory usage in your terminal constant and or they grow exponentially until crash? If the second, what is the latest value you can read? Golden rule is to keep them (the sum of objects + texture memory usage) well below 5 MB.
@Raom_games no that not case I felt like explain my problem a bit wrong ok here I go the problem is that when the two platforms move across the screen for about 30 seconds the simulator slows down then it stops responding. Then what I do is I force quit the simulator. Then I get the error in the terminal.
So I think I said myself wrong I meant to say simulator stops responding so I do fix this problem were the simulator stops responding.
ok i'm trying your file just now, let's see what happens
... and i can confirm it is a memory problem
please put the Ansca code into your main file and watch it going up exponentially before crashing ... in message #4 it was missing one line so you could not read anything from your terminal... so try this and watch yourself
1 2 3 4 5 6 7 8 9 10 | local function garbagePrinting() collectgarbage("collect") local memUsage_str = string.format( "memUsage = %.3f KB", collectgarbage( "count" ) ) print( memUsage_str ) local texMemUsage_str = system.getInfo( "textureMemoryUsed" ) texMemUsage_str = texMemUsage_str/1000 texMemUsage_str = string.format( "texMemUsage = %.3f MB", texMemUsage_str ) print( texMemUsage_str ) end Runtime:addEventListener( "enterFrame", garbagePrinting ) |
@Raom_games yeah I did see it so whats the solution to this problem
Edit: I just saw mines the simulator froze at when it reached memUsage = 108866.412 KB.
fatal problem should be here:
1 2 3 4 | function transit() transition.to(paddle, {time=2000 , x = 400 - 600, onComplete= recycle}) transition.to(paddle2, {time=2000, x = 480 - 600, onComplete= recycle}) end |
@Raom_games well thanks for detecting the problem
send message and call to a person
Forum: Report Spam + PM
[INSTALL_PARSE_FAILED_NO_CERTIFICATES]
[SOLVED] Director ERROR: Failed to execute new( params ) function on 'screen1'
Too many (200) local variables
Corona SVG Level Builder released. Drag and drop physics level editor with Inkscape and SVG.
Small bug in Collectible Items example
Pivot Joints and apparent elasticity
Can't make removeSelf() delayed
Audio playback is grinding my app to a halt. [Hair-pulling stage]
How do you properly deal with spritesheet removal with director class?
Capturing the version in code
Transparent PNG Layers problem
Posting to Facebook App Affected?
Panda Drop
Hunters' Moon (iPad)
To make a REALLY user-friendly game you need a 90-year-old beta tester!
Alerts not working on Device