I am creating a zombie game and the user has grenades that they can use . When the user touches the grenade it disappears . So what I want to have happen is an explosion happen at the bottom of the screen and then all the zombies in view get blasted away . I have a few sprite sheets but don’t know what to do with them . I have a sprite sheet for my zombie but I don’t think it’s the same as an explosion . Can someone help me out ? This is my zombie code :
local options = { --array of tables representing each frame (required) frames = { -- Frame 1 { --all parameters below are required for each frame x = 82, y = 1, width = 80, height = 110 }, -- Frame 2 { x = 1, y = 1, width = 80, height = 110 }, -- Frame 3 and so on... }, -- Optional parameters; used for scaled content support sheetContentWidth = 161, sheetContentHeight = 110 } local imageSheet = graphics.newImageSheet("leshy.png", options ) -- consecutive frames local sequenceData = { name="walking", start=1, count=2, time=750, loopCount = 0, -- Optional ; default is 0 (loop indefinitely) loopDirection = "forward" -- Optional ; values include "forward" or "bounce" } zombie = display.newSprite( imageSheet, sequenceData ) physics.addBody( zombie, "static", {density=3.0, friction=0.5, bounce=0.3, radius=12.5} ) zombie.xScale = -1 zombie:scale( 0.7, 0.7 ) zombie.x = 400 + 100 zombie.y = 280 zombie:play() transition.to( zombie, { x = zombie.x - 400, time = 8000, onComplete = function( self ) self:pause() end } ) --[[local zombie = display.newSprite( imageSheet, sequenceData ) zombie.xScale = -1 zombie.x = display.contentCenterX + 200 zombie.y = display.contentCenterY zombie:play() transition.to( zombie, { x = zombie.x - 400, time = 8000, onComplete = function( self ) self:pause() end } )]] Coins = 0 local centerX = 270 local centerY = 50 CoinsTxt = display.newText( "Coins: "..Coins, centerX, centerY, native.systemFontBold, 20 ) local options = { --array of tables representing each frame (required) frames = { -- Frame 1 { --all parameters below are required for each frame x = 82, y = 1, width = 80, height = 110 }, -- Frame 2 { x = 1, y = 1, width = 80, height = 110 }, -- Frame 3 and so on... }, -- Optional parameters; used for scaled content support sheetContentWidth = 161, sheetContentHeight = 110 } local imageSheet = graphics.newImageSheet("leshy.png", options ) -- consecutive frames local sequenceData = { name="walking", start=1, count=2, time=750, loopCount = 0, -- Optional ; default is 0 (loop indefinitely) loopDirection = "forward" -- Optional ; values include "forward" or "bounce" } zombie2 = display.newSprite( imageSheet, sequenceData ) physics.addBody( zombie2, "static", {density=3.0, friction=0.5, bounce=0.3, radius=12.5} ) zombie2.xScale = -1 zombie2:scale( 0.7, 0.7 ) zombie2.x = 400 + 100 zombie2.y = 280 zombie2:play() transition.to( zombie2, { x = zombie2.x - 400, time = 6000, onComplete = function( self ) self:pause() end } ) local options = { --array of tables representing each frame (required) frames = { -- Frame 1 { --all parameters below are required for each frame x = 82, y = 1, width = 80, height = 110 }, -- Frame 2 { x = 1, y = 1, width = 80, height = 110 }, -- Frame 3 and so on... }, -- Optional parameters; used for scaled content support sheetContentWidth = 161, sheetContentHeight = 110 } local imageSheet = graphics.newImageSheet("leshy.png", options ) -- consecutive frames local sequenceData = { name="walking", start=1, count=2, time=750, loopCount = 0, -- Optional ; default is 0 (loop indefinitely) loopDirection = "forward" -- Optional ; values include "forward" or "bounce" } zombie3 = display.newSprite( imageSheet, sequenceData ) physics.addBody( zombie3, "static", {density=3.0, friction=0.5, bounce=0.3, radius=12.5} ) zombie3.xScale = -1 zombie3:scale( 0.7, 0.7 ) zombie3.x = 400 + 100 zombie3.y = 280 zombie3:play() transition.to( zombie3, { x = zombie3.x - 400, time = 10000, onComplete = function( self ) self:pause() end } ) end local function grenadeTouch( event ) if event.phase == "ended" then display.remove(grenade1) end end local function grenade2Touch( event ) if event.phase == "ended" then display.remove(grenade2) end end local function grenade3Touch( event ) if event.phase == "ended" then display.remove(grenade3) end end