[lua]–animationTouch
module(…, package.seeall)
function new()
local localGroup = display.newGroup();
local sprite = require(“sprite”)
local sheet = sprite.newSpriteSheet(“images/touchSimple.png”, 50, 50)
local spriteSet = sprite.newSpriteSet(sheet, 1, 2)
sprite.add(spriteSet, “touchMe”, 1, 2, 10, 1)
local instance = sprite.newSprite(spriteSet)
instance:setReferencePoint(display.CenterReferencePoint);
instance.x = -500;
instance.y = -500;
localGroup:insert(instance);
function touchHandle(e)
if (e.phase == “began”) then
instance.x = e.x;
instance.y = e.y;
instance:prepare(“touchMe”)
instance:play()
end
if (e.phase == “moved”) then
instance.x = e.x;
instance.y = e.y;
end
if (e.phase == “ended”) then
instance.x = defaultPos;
instance.y = defaultPos;
end
end
Runtime:addEventListener(“touch”, touchHandle);
return localGroup;
end[/lua]
[lua]–stage1.lua
local locaGroup = display.newGroup();
local touchIcon = require(“animationTouch”).new()
localGroup:insert(touchIcon);[/lua]
@skalistican6 , here is my code.
Everything is fine for the first time but I got error which I’ve already mention in replay the scene.
@jstrahan
I do not get what you mention. Could you please give me some sample? [import]uid: 65906 topic_id: 15838 reply_id: 58534[/import]