Well that error is telling me you’re tapping the screen at some point where “bird” doesn’t exist. When it errored could you have gotten a tap in before the bird got re-created? Or perhaps you’re getting a different error?
Rob
Well that error is telling me you’re tapping the screen at some point where “bird” doesn’t exist. When it errored could you have gotten a tap in before the bird got re-created? Or perhaps you’re getting a different error?
Rob
My mouse does sometimes double left-click, but is that what is causing the problem? Should I put a boolean if-check inside restart.lua to see if it runs only once?
**edit**
So there’s a print() in both show’s for mainGame and Restart ‘did’ phase. I wanted to see if they were each being called only ONCE as it went from game, to restart, back to game, etc. This is what I get.
**edit**
After more testing, the game is fine when each game/restart show is called only once. when it happens twice in a row, I get the error.
**edit**
I believe I fixed the problem. So in mainGame’s scene:hide, I had the removeEventListeners in the ‘did’ phase, which meant that it could still take touch input during the ‘will’ phase, which sent it to the Restart screen twice. So I moved the removeEventListeners to the scene:hide ‘will’ phase and so far, I haven’t seen any duplicates, nor errors.
15:24:13.616 Should see this only once. 15:24:18.974 Restart - Show - should see this once. 15:24:19.116 Restart - Show - should see this once. 15:24:29.056 Should see this only once. 15:24:31.952 Restart - Show - should see this once. 15:24:37.146 Should see this only once. 15:24:44.837 Restart - Show - should see this once. 15:24:51.880 Should see this only once. 15:24:54.727 Restart - Show - should see this once. 15:24:58.743 Should see this only once. 15:25:04.235 Restart - Show - should see this once. 15:25:04.300 Restart - Show - should see this once. 15:25:07.774 Should see this only once. 15:25:08.739 Should see this only once. 15:25:09.038 Restart - Show - should see this once.
Look like most of the variables are not declared as ‘local’, and other files may overwrite it. Also notice you have alot of ‘enterFrame’. Not sure whether it will impact performance.
Try to check whether it is nil when doing something.
if ground1 ~= nil then ground1.enterFrame = scrollEnvironment end function activateFlight2(self) if self ~= nil then self:setLinearVelocity(0,0) end if self ~= nil then self:applyForce(0,-10,self.x,self.y) end end
Since your pc-mouse may be double-clicking, try putting a short timer to avoid double or fast touches
local isBusy = false function touchScreen(event) if event.phase == "began" then if isBusy == false then activateFlight2(bird) end isBusy = true local tmpTimer = timer.performWithDelay( 100, function() isBusy = false end ) -- Remember to stop this timer when exit scene. end end
Hope it helps.
Done and done. No more crashes as of late. Thanks for all the help.
Quick question, I do plan to add more to the game, so how would I go about limiting the amount of enterFrame callings?
-- Just call the 'enterFrame' once, and do all the logic in it -- Note : It can be 30fps (default) or 60fps. local function allLogic( event ) -- Do your checks in here for shrubs1, forest1, etc... end Runtime:removeEventListener("enterFrame", allLogic )
Just a sample based on https://docs.coronalabs.com/api/event/enterFrame/index.html
This thread is officially Solved. So thank you guys.
I’ll just continue to ask questions but you don’t need to answer them if you don’t want to.
In my global collision event, how do I differentiate between obstacles and power-ups?
local function onCollision(event) if event.phase == "began" then composer.gotoScene("restart", "fade", 400) end end
It’s currently used to detect collision with obstacles, and sends us to a restart scene.
I want to somehow detect a collision with boostPowerUp that will turn a bird.isBoost = true
Check our our getting started guide. The collision handling starts here:
https://docs.coronalabs.com/guide/programming/03/index.html#collision-handling
But you may want to read the while guide so you’re familiar with how things are setup.
Rob
Is there a way to change the simulator settings to see what my app would look like if I put it on different devices with different resolutions? Some of the coordinates are hard-coded and I’m afraid things will look odd on bigger devices.
Also, can someone point me in the direction of making this app Iphone-ready? I’m close to finishing and I really have no idea what to do next, but I know that I want to put it up on the markets.
You can use different skins in the simulator to see how your app will be have on different devices. You can also set custom resolutions if you want to test on a skin that we don’t support. From the simulator’s main menu do:
Window->View
and pick your choice from there.
As far as what to do next, test on a real device. There are quite a few things that behave differently between the simulator and a real device (like case sensitive file names – which should be producing warnings in the simulator’s console log). If you’re using Ads, GameCenter, In-App purchases or anything like that, those can only be tested on a device or the Xcode simulator (not the Corona Simulator).
Rob
I’ve been adding sound and music to the game, and some work and some don’t. They are all .wav format and I get this error for at least 3 sound/music files while the others work fine. Any ideas?
23:49:11.587 WARNING: C:\Users\Didier\Documents\Corona Projects\SpeedyBird\mainGame.lua:505: audio.loadStream() failed to create stream 'Inspired (Happy-Pop).wav' 23:49:14.508 WARNING: C:\Users\Didier\Documents\Corona Projects\SpeedyBird\restart.lua:106: audio.loadSound() failed to create sound 'menuSelect.wav' 23:49:14.518 WARNING: C:\Users\Didier\Documents\Corona Projects\SpeedyBird\restart.lua:107: audio.loadStream() failed to create stream 'funkyRooster.wav'
Some of the code:
menuSelect = audio.loadSound("menuSelect.wav") restartSound = audio.loadStream("funkyRooster.wav")
audio.play(restartSound, {channel = 2})
audio.stop(1) audio.stop(2) audio.dispose(menuSelect) audio.dispose(restartSound) menuSelect = nil restartSound = nil
HI @neviah.
Your latest question is doing something called “hijacking the thread”. We discourage this for a few reasons. First people search for forum posts looking for answers. If they search for audio questions and this thread shows up, they become confused. They read the first few posts and may not scroll all the way down to this point and this creates frustration for them. The other side of that is someone is looking for questions on transitioning to and from scenes, reads the thread and finds a bunch of audio talk. Again this frustrates the community.
When you have an un-related question to the thread, please start a new thread. We also have specific sub-forums to discuss audio. I would recommend creating a new thread is the audio subforum.
Rob