Discord
Login
Community
DARK THEME

Score counter

So I am making an apple catch! game. I am stuck on a simple counter. Like I try doing

update = function()

 for a in apples then
  if Quick.spriteCollision(a,player) then
     apples.remove()
     Quick.remove()
     Score+= 1
  end
 end
end

Well the score increases infinitely or like stop at 548 some time

I NEED HELP!

Shouldn't it be:

     apples.removeElement(a)
     Quick.remove(a)

Argument a is missing in your snippet.

Also I just edited my answer because I realized you have to use removeElement, rather than remove ; remove expects the index of the element you want to remove, not the object itself. If all you have is a reference to the element that should be removed, you have to use removeElement

Edit 2: Quick.removeElement(a) changed to Quick.remove(a), as pointed by @Crafterz125

Thank you all mighty gilles:)

I do it like this,

    apples.removeElement(a)
    Quick.remove(a)

since Quick Engine uses Quick.remove() rather than Quick.removeElement().

Correct, thanks for pointing the error, I edited my above reply.

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community