Raise user coins

When the bullet hits the character how do I add on to the users score ? This is what I have so far . 

function onCollision( event ) if event.phase =="began" then Coins = Coins + 1 end end

 centerX = 350 centerY = 60 Coins = 500 CoinsTxt = display.newText( "Coins: "..Coins, centerX, centerY, native.systemFontBold, 20 )

This code doesn’t work 

You need to update CoinsTxt each time.

How ?

I’m using storyboard 

A) You need to learn to look for simple stuff like this in the docs/google.

B) CoinsTxt.text = Coins

That code changes the whole text and it only works for 1 bullet . I also did look for this on the corona sdk site and google 

[lua]

local CoinsTxt

local Coins

–==========================================

local onCollision=function( event )
       

           if event.phase ==“began” then

                  Coins = Coins + 1

                  CoinsTxt.text="Coins: "…Coins

            end

end

–==========================================

Coins = 500

CoinsTxt = display.newText( "Coins: "…Coins, 100, 100, native.systemFontBold, 20 )

[/lua]

-Assif
 

Thanks it works 

:slight_smile: Most Welcome

You need to update CoinsTxt each time.

How ?

I’m using storyboard 

A) You need to learn to look for simple stuff like this in the docs/google.

B) CoinsTxt.text = Coins

That code changes the whole text and it only works for 1 bullet . I also did look for this on the corona sdk site and google 

[lua]

local CoinsTxt

local Coins

–==========================================

local onCollision=function( event )
       

           if event.phase ==“began” then

                  Coins = Coins + 1

                  CoinsTxt.text="Coins: "…Coins

            end

end

–==========================================

Coins = 500

CoinsTxt = display.newText( "Coins: "…Coins, 100, 100, native.systemFontBold, 20 )

[/lua]

-Assif
 

Thanks it works 

:slight_smile: Most Welcome