lua - HowTo create a fuel bar -
I would like to create a fuel bar (empty with full tank). When the user touches the screen, the fuel once Dairejh these is my code:
lifeBar = display.newImage ( "fuel_bar1.png") lifeBar.anchorX = 0 lifeboats. ======================== Lifetime Y = 37 screens Group: The Insert function (called Laifbar)
However, I fuel Kansmoshn (equivalent to "pressed" variable to reduce the fuel tank "true") Have used. When pressed == is true, it means that the user is touching the screen:
This function is active as the entrance event:
runtime: addEventListener ( "Antrfrem" fuel Snsadna)
it is very well, but my question is: pressed variable each time 5 seconds (once = = True) How is it possible to reduce the vitality width?
I tried to add it to my touch event function:
function flyup (event) if event.phase == "started" then = true = if wrong then play = Start = wrong pauseBtn.isVisible = true opt_btn.isVisible = true runtime: addEventListener ( "enterFrame", enterFrameListener) runtime: addEventListener ( "Antrfrem", scroll Grace) Taimrkprform Vidhel (5000, function () runtime: addEventListen AR ( "Enter Frame", Iyuelkansampshn) and, -1) Adiiiiif Iventkfesh == "end", then pressed = false timer Kprformdethelia (1000, function () Runtime: Htayenivent Listnr ( "Antrfrem" Fuel-Consopshn) and, -1) end end
The problem is that the code is very complete all memory Is doing and the game is very slow! So, is there any other way?
thanks :)
Instead of using a single image, a sprite sheet Use the. This will boost the game.
Comments
Post a Comment