need help with a source code

 i have a source code for a game written by corona sdk, there is a trouble with this game l:

  • when i get to high score like about 800>>1000 and lose the game, whenever i play it again, the speed of the first spaceship does not reset automatically, can anyone help me to solve that problem???.This is the source game of a free course i take online but the lecturer is no longer teach.

Hi

I had a little look at your game and found the solution for you.

Move the “speedBump=0” on line 93 to before the function call “spawnEnemy()”

like so…

local function goAway(event)
        display.remove(event.target)
        text = nil
        display.remove(gameTitle)
        speedBump = 0
        spawnEnemy()

        scoreTxt.alpha = 1
        scoreTxt.text = “Score: 0”
        score = 0
        planet.numHits = 10
        planet.alpha = 1
    end

It works in my simulator.

Best of luck…

Thanks so much, i stuck with this trouble for a very long time :slight_smile:

Glad to help

Hi

I had a little look at your game and found the solution for you.

Move the “speedBump=0” on line 93 to before the function call “spawnEnemy()”

like so…

local function goAway(event)
        display.remove(event.target)
        text = nil
        display.remove(gameTitle)
        speedBump = 0
        spawnEnemy()

        scoreTxt.alpha = 1
        scoreTxt.text = “Score: 0”
        score = 0
        planet.numHits = 10
        planet.alpha = 1
    end

It works in my simulator.

Best of luck…

Thanks so much, i stuck with this trouble for a very long time :slight_smile:

Glad to help