Timer on Power-Ups

This should be quick question for anybody who can help me out here. In my game I have a couple of power ups. Some are one time things like extra life or added points, but some are score multipliers. I would like some guidance in how to make a sort of timer so that a powerup lasts for maybe 15 seconds and then goes away. This is what a section looks like right now:

if (powerUpNumber == 1) then scoreDoubleBar = display.newImage("scoreDoubleBar.png") scoreDoubleBar.y = 40 transition.from(scoreDoubleBar, {alpha = 0}) doubleScoreMode = true end if (powerUpNumber == 2) then scoreTripleBar = display.newImage("scoreTripleBar.png") scoreTripleBar.y = 40 transition.from(scoreTripleBar, {alpha = 0}) tripleScoreMode = true end

So it would be something like if power-up number one was chosen, the scoreDoubleBar (which is a picture) would appear and the scoreDoubleMode would turn on. Then after 15 seconds, scoreDoubleBar would scoreDoubleBar:removeSelf() and scoreDoubleBar would be false.

Thanks for your time! [import]uid: 7116 topic_id: 12257 reply_id: 312257[/import]

This should work:

[code]

function removeMultiplier()
scoreDoubleBar:removeSelf()
end

timer.performWithDelay( 15000, removeMultiplier, 1 )

[/code] [import]uid: 24111 topic_id: 12257 reply_id: 44644[/import]

Hey there, Oskwish’s suggestion is a good one - I use a power up in one of my templates and use a timer, as he does.

Just start the timer when the power up is collected/activated/etc

:slight_smile: [import]uid: 52491 topic_id: 12257 reply_id: 44655[/import]