local touchTest = class(“touchTest”,function ()
return display.newScene(“touchTest”)
end)
function touchTest:ctor ()
print(“nihao”)
local sp = cc.Sprite:create(“grossini_dance_08.png”)
sp:setPosition(display.cx,display.cy)
sp:addTo(self)
local touchBeginPoint =nil
local function onTouchBegan (touch,event)
local location = touch:getLocation()
print("onTouchBeagn:%0.2f,%0.2f",location.x,location.y)
print("onTouchBegan")
end
local function onTouchMove (touch,event)
local location = touch:getLocation()
print("onTouchBeagn:%0.2f,%0.2f",location.x,location.y)
print("onTouchMove")
end
local function onTouchEnd(touch,event)
local location = touch:getLocation()
cclog("onTouchBeagn:%0.2f,%0.2f",location.x,location.y)
print("onTouchEnd")
end
local listener = cc.EventListenerTouchOneByOne:create()
listener:registerScriptHandler(onTouchBegan,cc.Handler.EVENT_TOUCH_BEGAN)
listener:registerScriptHandler(onTouchMove,cc.Handler.EVENT_TOUCH_MOVED)
listener:registerScriptHandler(onTouchEnd,cc.Handler.EVENT_TOUCH_ENDED)
local eventDispatcher = cc.Director:getInstance():getEventDispatcher()
eventDispatcher:addEventListenerWithSceneGraphPriority(listener,self)
end
function touchTest:onEnter()
end
function touchTest:onExit()
end
return touchTest;