Greeting all,
i am trying to make the listView selection touch --> detail page
the detail page can create an ImageObject, and able to drag
here my code change
--setup functions to execute on touch of the list view items
function listButtonRelease( event )
self = event.target
local id = self.id
print(self.id)
-- weilies, create image
local myCoffee = display.newImage(data[id].image)
myCoffee:addEventListener( "touch", startDrag )
detailScreenText.text = "You tapped ".. data[id].title --added this line to make the right side of the screen more interesting
--check for screen width of the iPad
if system.getInfo("model") == "iPad" then
selected.width, selected.height = self.width, self.height --iPad: set the color fill width and height
selected.y = self.y + self.height\*0.5 --iPad: move the color fill to wherever the user tapped
selected.isVisible = true --iPad: show the fill color
else
transition.to(myList, {time=400, x=display.contentWidth\*-1, transition=easing.outExpo })
transition.to(detailScreen, {time=400, x=0, transition=easing.outExpo })
transition.to(backBtn, {time=400, x=math.floor(backBtn.width/2) + screenOffsetW\*.5 + 6, transition=easing.outExpo })
transition.to(backBtn, {time=400, alpha=1 })
delta, velocity = 0, 0
end
-- A basic function for dragging physics objects
local function startDrag( event )
local t = event.target
--[[
local phase = event.phase
if "began" == phase then
display.getCurrentStage():setFocus( t )
t.isFocus = true
-- Store initial position
t.x0 = event.x - t.x
t.y0 = event.y - t.y
-- Make body type temporarily "kinematic" (to avoid gravitional forces)
event.target.bodyType = "kinematic"
-- Stop current motion, if any
event.target:setLinearVelocity( 0, 0 )
event.target.angularVelocity = 0
elseif t.isFocus then
if "moved" == phase then
t.x = event.x - t.x0
t.y = event.y - t.y0
elseif "ended" == phase or "cancelled" == phase then
display.getCurrentStage():setFocus( nil )
t.isFocus = false
-- Switch body type back to "dynamic", unless we've marked this sprite as a platform
if ( not event.target.isPlatform ) then
event.target.bodyType = "dynamic"
end
end
end
]]--
-- Stop further propagation of touch event!
return true
end
end
but seems like it gave me error below
Copyright (C) 2009-2010 A n s c a , I n c .
Version: 1.0.0
Build: 2010.109
The file sandbox for this project is located at the following folder:
(/Users/admin/Library/Application Support/Corona Simulator/CoffeeDemo-C2A3DE8306CA6962BDD32F0CEB59F8CA)
touch: began
highlight
touch: ended
2
Runtime error
assertion failed!
stack traceback:
[C]: ?
[C]: in function 'assert'
?: in function 'getOrCreateTable'
?: in function 'addEventListener'
/Users/admin/Desktop/myCorona/CoffeeDemo/main.lua:64: in function 'onRelease'
...sers/admin/Desktop/myCorona/CoffeeDemo/tableView.lua:119: in function <...sers><br> ?: in function <?:214><br> [import]uid: 10373 topic_id: 3665 reply_id: 303665[/import] </…sers>