How can i display lives in numbers?

I already know how to display lives with images (ex: hearts and stuff) but how can i display lives in numbers instead of images? thanks [import]uid: 10827 topic_id: 6600 reply_id: 306600[/import]

http://developer.anscamobile.com/content/displaynewtext [import]uid: 12108 topic_id: 6600 reply_id: 22971[/import]

awesome thanks… how do i make it go from 5 lives to 4 lives to 3 etc. everytime i lose a life? [import]uid: 10827 topic_id: 6600 reply_id: 23033[/import]

Say your text object is called livesDisplay, you would just set the .text property of it:
[lua]–Change the number of lives
lives = lives -1
livesDisplay.text = lives[/lua] [import]uid: 8782 topic_id: 6600 reply_id: 23067[/import]

oh awesome thanks! works wonderfully, im trying to change scenes when the lives = 0 so how can i do this? i put this…but it doesnt work

local function killCrate (event) crate:removeSelf() lives = lives -1 livesDisplay.text = lives if lives == 0 then director:changeScene("gameover") end [import]uid: 10827 topic_id: 6600 reply_id: 23100[/import]

figured it out, thanks again! [import]uid: 10827 topic_id: 6600 reply_id: 23141[/import]

I’m really not getting this. I have bombs in my game. My text object is called bombCount and by default it displays the number “3.” When the object bombButton is tapped I want the bombCount to decrease by one. At the moment I have this:

function bombButton:tap( event )  
 audio.play( bombSound )  
 bombButton.alpha = .5  
 function returnColor (event)  
 bombButton.alpha = 1  
 end  
 timer.performWithDelay ( 250, returnColor, 1)  
end  
bombButton:addEventListener( "tap", bombButton)  

From what I read here I think I need to have something like “bombCount = bombCount -1” in there somewhere but I don’t know where to put it or how to make it work. [import]uid: 35706 topic_id: 6600 reply_id: 25063[/import]

Just put bombCount = bombCount - 1 right underneath where you set the alpha property. You could place it several places, but that’s as good as any.

Since Lua is a “typeless” language you can set the text property as “3” and still perform subtraction on it – and then display it as text again.

Jay

PS - I just posted a longer description of this on my blog:
http://gamedevnation.com/?p=171
[import]uid: 9440 topic_id: 6600 reply_id: 25066[/import]

Awesome, thanks! It wasn’t working for me at first, but after some trial & error I realized I could just say “bombs = 3” and then have that feed into the bombCount. [import]uid: 35706 topic_id: 6600 reply_id: 25365[/import]