basically we have a button and we have a bunch of zombies spawning in every so seconds, we want it so that once the button is pressed we want all the zombies to transition to the left. here is the code we have that includes the zombies spawning and our button
if the buttons don’t work its because we didn’t include the photos so just use anything if u want to test it
local function spawnzombie()
local zombie = display.newImageRect(“zombie.jpg”, 45, 45);
zombie.x = 200;
zombie.y = 200;
function movezombie()
transition.to(zombie,{time=7000, x=math.random(0,500), y=math.random(0,600), onComplete=movezombie});
end
physics.addBody(zombie, “dynamic”, {density = 0.1, bounce = 0.1, friction = .1, radius = 0});
movezombie()
--Adding touch event
zombie:addEventListener(“touch”, zombie);
zombie.collType = “none”
physics.addBody( zombie, { bounce=10.0, friction=1.0 } )
function onCollision(event)
–print(“collide!”)
happy:removeSelf()
end
Runtime:addEventListener(“collision”, onCollision)
end
local total_zombie = 100
tmr = timer.performWithDelay(2000, spawnzombie, total_zombie);
– BUTTON code
local widget = require( “widget” )
local function handleButtonEvent( event )
local phase = event.phasr
if “ended” == phase then
print( “you pressed and released a button!” )
end
end
local myButton = widget.newButton
{
left = 800,
top = 400,
width = 100,
height = 100,
defaultFile = “button1.jpg”,
overFile = “smallbutton.png”,
label = “GRENADE”,
onEvent = handleButtonEvent,
}