It looks like you're new here. If you want to get involved, click one of these buttons!
--settings application: setLogicalDimensions (720, 1440) application: setScaleMode ('letterbox') application: setOrientation ('portrait') application: setKeyboardVisibility (false) application: setKeepAwake (true) application: setFps (60) application: setBackgroundColor (0x11272c) w, h = application:getLogicalWidth(), application:getLogicalHeight() -- Function that record a gesture and replays it --Create box local img = Pixel.new(0xffffff,1,50,50) img:setAnchorPoint(0.5, 0.5) stage:addChild(img) --Table and array for saving coordinate local g = {} local i = 1 local function d(event) --Gets the starting point g = nil g = {} collectgarbage() i = 1 g[i] = {event.touch.x, event.touch.y} end stage:addEventListener(Event.TOUCHES_BEGIN, d) local function m(event) --saves coordinate inside the table i = i + 1 g[i] = {event.touch.x, event.touch.y} end stage:addEventListener(Event.TOUCHES_MOVE, m) local function u(event) --replay the coordinates from table using gtween i = 1 img:setPosition(g[i][1], g[i][2]) local function run() local t = GTween.new(img, 0.01, {x = g[i][1], y= g[i][2]}, {delay = 0, ease = easing.linear, dispatchEvents = true}) t:addEventListener('complete', function() if i < #g then i = i + 1 run() end end) end run() end stage:addEventListener(Event.TOUCHES_END, u) --I would also like to put trail on the gesture, like a doodling effect but I don't know how |
Likes: koeosstudio, MoKaLux
Comments
in your case i also don't get the use of the run() function (and the tween inside) as you anyway position the img at the position g[i][1],g[i][2] so the tween does nothing as far as i see.
about the trail:
in your case perhaps you could just have 10 img's with different opacity that all follow the trail but shifted by one in the table.
btw i've made a whole app around the 'trail effect':
https://longtitleproductions.bitbucket.io/fragmenter/fragmenterapp.html
Likes: koeosstudio
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Thanks for the trail effect
Fragmenter - animated loop machine and IKONOMIKON - the memory game