Hello Corona Community!
I am making a game, it involves counting collisions in order to keep score. Getting a score counter to work is done, but now i would like to add a “streak counter” which increments up on score, and resets to zero on a floor collision. I would like to save streak score before it resets to zero in another text box. This other text box would then hold the saved score until a higher streak was achieved, then increase to the new score.
the issue:
the high score counter doesn’t go past 9, even if the multiplier does
…and I’m new to coding :), and somewhat confused
code provided, thanks in advance for any assistance
----------------------------------------------------------------------------------------- local mScore = 0 local mScore = display.newText(mScore, 150, 0, nil, 42); mScore:setTextColor(0,100,235) mScore.y = 800 mScore.x = 460 local cScore = 0 local cScore = display.newText(cScore, 150, 0, nil, 42); cScore:setTextColor(0,100,235) cScore.x = 460 cScore.y = 760 local hScore = 0 local hScore = display.newText(hScore, 150, 0, nil, 38); hScore:setTextColor(0,100,235) hScore.y = 940 hScore.x = 320 local dScore = display.newText("SCORE!", 30, 9, nil, 28) dScore:setTextColor(0,100,235) dScore.x = 186 dScore.y = 760 local streakScore = display.newText("STREAK!", 30, 9, nil, 28) streakScore:setTextColor(0,100,235) streakScore.x = 186 streakScore.y = 790 local hstreakScore = display.newText("STREAK TO BEAT!", 30, 9, nil, 28) hstreakScore:setTextColor(0,100,235) hstreakScore.x = 320 hstreakScore.y = 900 ----------------------------------------------------------------------------------------- function borderBottomCollision( borderBottom, event ) if ( event.other.myName == "kernel" ) then mScore.text = mScore.text - mScore.text event.other:removeSelf() bloopChannel = audio.play( bloopSound ) print("reset") end if ( event.other.myName == "kernel2" ) then mScore.text = mScore.text - mScore.text event.other:removeSelf() bloopChannel = audio.play( bloopSound ) print("reset") end end function playerOneCollision( playerOne, event ) if ( event.other.myName == "kernel" ) then event.other:removeSelf() cScore.text = cScore.text + 1 mScore.text = mScore.text + 1 if ( mScore.text \> hScore.text ) then hScore.text = mScore.text end if ( mScore.text \< hScore.text ) then hScore.text = hScore.text end end if ( event.other.myName == "kernel2" ) then event.other:removeSelf() cScore.text = cScore.text + 1 mScore.text = mScore.text + 1 if ( mScore.text \> hScore.text ) then hScore.text = mScore.text end if ( mScore.text \< hScore.text ) then hScore.text = hScore.text end end end local function flick(event) if event.phase == "moved" then system.vibrate() local diffX = event.xStart - event.x local diffY = event.yStart - event.y if math.abs(diffX) \> 1 or math.abs(diffY) \> 1 then playerOne:applyForce( (playerOne.x) \* diffX/-3000, (playerOne.y) \* diffY/-2000, playerOne.x, playerOne.y ) end end end