I am a newbie to Corona SDK. I am trying to drag the fruits on the screen. I am having a “stack traceback” error code on the function “dragFruits…” line. I copy this same block of code on one of the Corona youtube videos.
However, I am stuck and do not know exactly on what to do.
Any help will be appreciated. Thanks.
local fruitShuffle = require("TableShuffle") local fruits = require("fruits") local fruitSheet = graphics.newImageSheet( "fruits.png", fruits:getSheet() ) t = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32} shuffleTable = shuffle(t) s = {t[1],t[2],t[3],t[4],t[5],t[6]} shuffleTable = shuffle(s) function dragFruits:touch(event) if event.phase == "began" then self.markX = self.x self.markY = self.y elseif event.phase == "moved" then local x = (event.x - event.xStart) + self.markX local y = (event.y - event.yStart) + self.markY self.x, self.y = x, y end return true end showFruitsSeqData = { {name="S1",sheet=fruitSheet,frames={s[1]} }, {name="S2",sheet=fruitSheet,frames={s[2]} }, {name="S3",sheet=fruitSheet,frames={s[3]} }, {name="S4",sheet=fruitSheet,frames={s[4]} }, {name="S5",sheet=fruitSheet,frames={s[5]} }, {name="S6",sheet=fruitSheet,frames={s[6]} } } showFruits = display.newImageRect( fruitSheet, s[1], 80, 80) showFruits.x = 50 showFruits.y = 25 -- showFruits:addEventListener( "touch", dragFruits )