cocos code ide + lua
cc.Director:getInstance():getOpenGLView():setDesignResolutionSize(960, 640, 1);
之后,添加了触摸事件,触摸左下角的时候,坐标不是应该是0+,0+ 吗?
为什么,输出的坐标会是0+,23+....
上完整代码 补充一下,是cocos code ide bate版本
-------------------------------
local function main()
cc.Director:getInstance():setDisplayStats(false);
cc.Director:getInstance():getOpenGLView():setDesignResolutionSize(960, 640, 1);
local scene = cc.Scene:create();
local layer = cc.Layer:create();
scene:addChild(layer);
local function onTouchBegan(touch,event) --@return typeOrObject
print(touch:getLocation().x,touch:getLocation().y);
return true;
end
local listener = cc.EventListenerTouchOneByOne:create();
listener:registerScriptHandler(onTouchBegan,cc.Handler.EVENT_TOUCH_BEGAN );
local eventDispatcher = layer:getEventDispatcher();
eventDispatcher:addEventListenerWithSceneGraphPriority(listener, layer);
if cc.Director:getInstance():getRunningScene() then
cc.Director:getInstance():replaceScene(scene)
else
cc.Director:getInstance():runWithScene(scene)
end
end
main();