A few questions and need some help

1 reply [Last post]
TheAttempts
User offline. Last seen 4 years 5 weeks ago. Offline
Joined: 5 Aug 2011

I used to script in lua but none of it was really hard coded, i script in other languages so are any like lua? if so what languages are like lua. Also since i practically just started in lua what is the best way (your recommendations)to learn it. Currently i am working on my first lua game and basically what i got so far is the background in the sky, i made a balloon in Gimp, and i have a balloon spawner script going. gravity is negative so the balloons float upward and you are suppose to tap the balloons and they will pop. i havent gotten to the pop part because i dont really know how i should do it but im trying to atleast get it to play this balloon popping noice.

Here is my code so far

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
system.activate("multitouch")
        
        local physics = require("physics")
                physics.start()
                physics.setGravity(0, -2)
 
        local background = display.newImage("bkg_background001.png")
 
        local isPaused = false
                
        local function spawnBalloon( event )
                balloon = display.newImage("balloon001.png")
                balloon.x = math.random(500)
                balloon.y = 1100
                balloon.rotation = 0
                --balloon.name("balloon")
                physics.addBody( balloon, {friction = 0.5})
                balloon.collision = onCollide
                
        balloon:addEventListener("collision", balloon)
        if(balloon:addEventListener( "touch", balloon)) then
                media.playsound("popSound")
        end
        end
        
        local function PausePlay()
                pause = display.newImage("pause.png")
                pause.x = ScreenWidth/2
                pause.y = ScreenHeight/2
                play = display.newImage("play.png")
                
                if(pause:addEventListener( "touch", pause)) then
                        system.vibrate()
                        
                end
        end
                
                display.setStatusBar(display.HiddenStatusBar)
                        
                timer.performWithDelay(500, spawnBalloon, 500)

Im also trying to get it to pause but i dont really know how to do the applicationsuspend and applicationresume i tried looking stuff up but im a little tired so i really didnt find anything

Replies

renvis@technowand
User offline. Last seen 2 weeks 5 days ago. Offline
Joined: 22 Jun 2011

to do the popping animation you can use movieclips or spritesheets. both will show a sequence of images to get an animated popping effect.

to implement pause in above code you have to do 3 things
1. pause physics (use physics.pause())
2. stop the timer which calls spawnBalloon
3. remove the event listener attached to the current baloon

Happy Coding :)
Renjith
www.technowand.com

Viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.