1 Reply Latest reply on May 22, 2006 9:05 AM by FMF Assistans

# car game, count points when 2 sprite intercepts

I am building a car game and need a text field to count when 2 sprites intercepts.

text field lingo:
global gCounter

on enterFrame me
sprite(the currentSpriteNum).member.text = string(gCounter)
end

objekt lingo:
property pMyS
global gCounter
property pFlag

on beginSprite me
pMyS = sprite(the currentSpriteNum)
pFlag = 1
end

on enterFrame me
if sprite the currentSpriteNum intersects sprite 18 and pFlag = 1 then
gCounter = gCounter +1
pFlag=0
else
gCounter = gCounter +0
end if
pMyS.locV = pMyS.locV + 2
if sprite the currentSpriteNum intersects sprite 18 then
pMyS.locV = - 100
pMyS.locH = random(700)
if pMyS.locH <= 233 then
pMyS.locH = 233 + random(50)
end if
if pMyS.locH >= 373 then
pMyS.locH = 373 - random(50)
end if
end if
if sprite the currentSpriteNum intersects sprite 19 then
pMyS.locV = - 100
pMyS.locH = random(700)
if pMyS.locH <= 233 then
pMyS.locH = 233 + random(50)
end if
if pMyS.locH >= 373 then
pMyS.locH = 373 - random(50)
end if
end if
end

the problem is that it only count 1 time, I need to start the game agin to get next count.
How can i get it to allwas start on zero and make it count every time the sprites intercepts?
• ###### 1. Re: car game, count points when 2 sprite intercepts
I solved the problem with one count by taking away property pFlag.

now i need it to go back to zero after restart ore next level.