I'm new to this forum and my english not realy good, sorry.
So, i stucked with animation.
Here is the video of what i wanted:
(dont know how to paste it with tag, sry
)
I were made it by using timers. Like that:
function onAnimate(P)
P:animate() -- updating picture of piece (P)
P:shake(.7, 10, 10)
end
function tap(x,y)
-- some code
for ix = a, b do -- vertical line
if Array[y][ix] ~= 0 then -- checking if cell not empty
Array[y][ix]:switchState(false) -- switching value without updating a picture
local aTimer = Timer.new(delay, 1) -- delay is calculated dynamically (something like that: (ix-2)*25)
aTimer:start()
aTimer:addEventListener(Event.TIMER_COMPLETE, onAnimate, Array[y][ix])
else break end
end
end |
Each piece stored in the "Array" (as object ofcourse), and it have two states (on/off), also it have three methods:
-- update picture
function Piece:animate()
if self:contains(self.frames[math.abs(self.state-2)]) then
self:removeChild(self.frames[math.abs(self.state-2)])
end
if not self:contains(self.frames[self.state+1]) then
self:addChild(self.frames[self.state+1])
end
end
function Piece:setState(s, animate)
self.state = s
if animate then
self:animate()
end
if self.arrow ~= nil then self:addChild(self.arrow) end
end
function Piece:switchState(animate)
if animate == nil then animate = true end
self:setState(math.abs(self.state-1), animate)
end |
Everything works fine on my PC, but on Android device GiderosAndroidPlayer crashing if i'll be touching pieces very fast.
Any ideas how to make this effect without timers? Or how to avoid crashes on mobile devices...
And again, sorry for my bad language
Comments
Just added timer to Piece class:
Likes: ar2rsawseen