Game Help!

Hey everybody, thanks for future replies! Okay so I have this:

function prepareMoles()

        for i = 1, 1 do

        

        mole = display.newImage(‘mole.png’, 200, 200)

        mole:addEventListener(“tap”, moleHit)

        mole.isVisible = false

        mole.id = i

          

        moles[i] = mole

                   <------ Here?

        end

        startTimer() 

end 

function startTimer()    

    timerSource = timer.performWithDelay(1400, showMole, 0)

end

function showMole(e)

    if(currentMoles == totalMoles) then

        alert()

    else

        lastMole.isVisible = false

        local randomHole = math.random(1, 1)

    

        lastMole = moles[randomHole]

        lastMole:setReferencePoint(display.BottomCenterReferencePoint)

        lastMole.yScale = 0.1

        lastMole.isVisible = true

        

        Runtime:addEventListener(‘enterFrame’, popOut)

        

        currentMoles = currentMoles + 1

    end

end

I want to add another “MOLE” in the display.group but that has a different function. How and where would I put it at ? any help will be greatly appreciated!

Hello, first off please use the code tags to make your code more readable.  You can find it in the toolbar, it looks like this <>

To answer your question, you can do something like this:

function prepareMoles() for i = 1, 1 do mole = display.newImage('mole.png', 200, 200) mole:addEventListener("tap", moleHit) mole.isVisible = false mole.id = i mole.type = "Fast" moles[i] = mole end startTimer() end 

Then in your function do a test to see which type of mole it is, then perform whatever action you need.

Thanks for the reply!

So for example if i wanted to add another different type of “mole” it would be like this: ?

function prepareMoles()

for i = 1, 1 do

mole = display.newImage(‘mole.png’, 200, 200)
mole:addEventListener(“tap”, moleHit)
mole.isVisible = false
mole.id = i
mole.type = “Fast”

<----- Here?

mole1 = display.newImage(‘mole1.png’, 200, 200)

mole1:addEventListener(“tap”,moleHit)

mole1.isVisible = false

mole1.id = i

mole.type = “Slow”

moles[i] = mole
moles[i] = mole1

end

startTimer()
end

and again thanks a lot for your replies! greatly appreciated. 

Hello, first off please use the code tags to make your code more readable.  You can find it in the toolbar, it looks like this <>

To answer your question, you can do something like this:

function prepareMoles() for i = 1, 1 do mole = display.newImage('mole.png', 200, 200) mole:addEventListener("tap", moleHit) mole.isVisible = false mole.id = i mole.type = "Fast" moles[i] = mole end startTimer() end 

Then in your function do a test to see which type of mole it is, then perform whatever action you need.

Thanks for the reply!

So for example if i wanted to add another different type of “mole” it would be like this: ?

function prepareMoles()

for i = 1, 1 do

mole = display.newImage(‘mole.png’, 200, 200)
mole:addEventListener(“tap”, moleHit)
mole.isVisible = false
mole.id = i
mole.type = “Fast”

<----- Here?

mole1 = display.newImage(‘mole1.png’, 200, 200)

mole1:addEventListener(“tap”,moleHit)

mole1.isVisible = false

mole1.id = i

mole.type = “Slow”

moles[i] = mole
moles[i] = mole1

end

startTimer()
end

and again thanks a lot for your replies! greatly appreciated.