Hi,
I have a sprite sheet of a frog jumping that I created using texture packer. And what I want to achieve is when I click on the image the frog jumps forward a certain distance and stops until it is click again. I’ve managed to load the sprite and get the frog sprite to play when clicked (touched) but I am having a little trouble with stopping the sprite and how-to get it to jump forward here is the code so far:
[code]
local sprite = require “sprite”
local sheetData = require “myFrogs” – name of file created using texture packer
local _w = display.contentWidth/2
local _h = display.contentHeight/2
local spriteData = sheetData.getSpriteSheetData()
local spriteSheet = sprite.newSpriteSheetFromData(“images/myFrogs.png”, spriteData)
local spriteSet = sprite.newSpriteSet(spriteSheet, 1, 7) – number of images in spritesheet
local frogSprite = sprite.newSprite(spriteSet)
frogSprite.x = _w
frogSprite.y = _h
–when I uncomment this code the frog animation doesn’t play
–local function frogStop (event)
– if (event.phase ==“ended”) then
– frogSprite:pause()
–end
–end
–Runtime:addEventListener(“touch”, frogStop )
– code for frog animation
local function frogJump(event)
if(event.phase == “ended”) then
– can I use frogSprite:setLinearVelocity(x,y) here to have the frog jump forward?
frogSprite:play()
end
end
frogSprite:addEventListener(“touch”, frogJump)
[code] [import]uid: 167310 topic_id: 32143 reply_id: 332143[/import]