mirror of https://github.com/axmolengine/axmol.git
issue #3837:Add debug support for lua template
This commit is contained in:
parent
48498f726e
commit
6a927c3f18
|
@ -17,6 +17,13 @@ local function main()
|
|||
collectgarbage("setpause", 100)
|
||||
collectgarbage("setstepmul", 5000)
|
||||
|
||||
--support debug
|
||||
local targetPlatform = cc.Application:getInstance():getTargetPlatform()
|
||||
if (cc.PLATFORM_OS_IPHONE == targetPlatform) or (cc.PLATFORM_OS_IPAD == targetPlatform) or
|
||||
(cc.PLATFORM_OS_ANDROID == targetPlatform) or (cc.PLATFORM_OS_WINDOWS == targetPlatform) or
|
||||
(cc.PLATFORM_OS_MAC == targetPlatform) then
|
||||
require('mobdebug').start()
|
||||
end
|
||||
require "hello2"
|
||||
cclog("result is " .. myadd(1, 1))
|
||||
|
||||
|
@ -103,43 +110,39 @@ local function main()
|
|||
|
||||
-- handing touch events
|
||||
local touchBeginPoint = nil
|
||||
|
||||
local function onTouchBegan(x, y)
|
||||
cclog("onTouchBegan: %0.2f, %0.2f", x, y)
|
||||
touchBeginPoint = {x = x, y = y}
|
||||
local function onTouchBegan(touch, event)
|
||||
local location = touch:getLocation()
|
||||
cclog("onTouchBegan: %0.2f, %0.2f", location.x, location.y)
|
||||
touchBeginPoint = {x = location.x, y = location.y}
|
||||
spriteDog.isPaused = true
|
||||
-- CCTOUCHBEGAN event must return true
|
||||
return true
|
||||
end
|
||||
|
||||
local function onTouchMoved(x, y)
|
||||
cclog("onTouchMoved: %0.2f, %0.2f", x, y)
|
||||
local function onTouchMoved(touch, event)
|
||||
local location = touch:getLocation()
|
||||
cclog("onTouchMoved: %0.2f, %0.2f", location.x, location.y)
|
||||
if touchBeginPoint then
|
||||
local cx, cy = layerFarm:getPosition()
|
||||
layerFarm:setPosition(cx + x - touchBeginPoint.x,
|
||||
cy + y - touchBeginPoint.y)
|
||||
touchBeginPoint = {x = x, y = y}
|
||||
layerFarm:setPosition(cx + location.x - touchBeginPoint.x,
|
||||
cy + location.y - touchBeginPoint.y)
|
||||
touchBeginPoint = {x = location.x, y = location.y}
|
||||
end
|
||||
end
|
||||
|
||||
local function onTouchEnded(x, y)
|
||||
cclog("onTouchEnded: %0.2f, %0.2f", x, y)
|
||||
local function onTouchEnded(touch, event)
|
||||
local location = touch:getLocation()
|
||||
cclog("onTouchEnded: %0.2f, %0.2f", location.x, location.y)
|
||||
touchBeginPoint = nil
|
||||
spriteDog.isPaused = false
|
||||
end
|
||||
|
||||
local function onTouch(eventType, x, y)
|
||||
if eventType == "began" then
|
||||
return onTouchBegan(x, y)
|
||||
elseif eventType == "moved" then
|
||||
return onTouchMoved(x, y)
|
||||
else
|
||||
return onTouchEnded(x, y)
|
||||
end
|
||||
end
|
||||
|
||||
layerFarm:registerScriptTouchHandler(onTouch)
|
||||
layerFarm:setTouchEnabled(true)
|
||||
local listener = cc.EventListenerTouchOneByOne:create()
|
||||
listener:registerScriptHandler(onTouchBegan,cc.Handler.EVENT_TOUCH_BEGAN )
|
||||
listener:registerScriptHandler(onTouchMoved,cc.Handler.EVENT_TOUCH_MOVED )
|
||||
listener:registerScriptHandler(onTouchEnded,cc.Handler.EVENT_TOUCH_ENDED )
|
||||
local eventDispatcher = layerFarm:getEventDispatcher()
|
||||
eventDispatcher:addEventListenerWithSceneGraphPriority(listener, layerFarm)
|
||||
|
||||
return layerFarm
|
||||
end
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -32,4 +32,5 @@
|
|||
android:normalScreens="true"
|
||||
android:largeScreens="true"
|
||||
android:xlargeScreens="true"/>
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
</manifest>
|
||||
|
|
|
@ -55,6 +55,8 @@
|
|||
15A8A4851834C73500142BE0 /* libCocosDenshion Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 15A8A41F1834BDA200142BE0 /* libCocosDenshion Mac.a */; };
|
||||
15A8A4861834C73500142BE0 /* libluabindings Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 15A8A4231834BDA200142BE0 /* libluabindings Mac.a */; };
|
||||
15A8A4881834C90F00142BE0 /* libcurl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 15A8A4871834C90E00142BE0 /* libcurl.dylib */; };
|
||||
15FFA0FD1894DDEF00C96D45 /* mobdebug.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15FFA0FC1894DDEF00C96D45 /* mobdebug.lua */; };
|
||||
15FFA0FE1894DDEF00C96D45 /* mobdebug.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15FFA0FC1894DDEF00C96D45 /* mobdebug.lua */; };
|
||||
1AC3622F16D47C5C000847F2 /* background.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = 1AC3622316D47C5C000847F2 /* background.mp3 */; };
|
||||
1AC3623016D47C5C000847F2 /* background.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 1AC3622416D47C5C000847F2 /* background.ogg */; };
|
||||
1AC3623116D47C5C000847F2 /* crop.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AC3622516D47C5C000847F2 /* crop.png */; };
|
||||
|
@ -246,6 +248,7 @@
|
|||
15A8A4631834C6AD00142BE0 /* StudioConstants.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = StudioConstants.lua; path = ../cocos2d/cocos/scripting/lua/script/StudioConstants.lua; sourceTree = "<group>"; };
|
||||
15A8A4871834C90E00142BE0 /* libcurl.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libcurl.dylib; path = usr/lib/libcurl.dylib; sourceTree = SDKROOT; };
|
||||
15C1568D1683131500D239F2 /* libcurl.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libcurl.a; path = ../cocos2d/cocos2dx/platform/third_party/ios/libraries/libcurl.a; sourceTree = "<group>"; };
|
||||
15FFA0FC1894DDEF00C96D45 /* mobdebug.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = mobdebug.lua; sourceTree = "<group>"; };
|
||||
1AC3622316D47C5C000847F2 /* background.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; name = background.mp3; path = ../Resources/background.mp3; sourceTree = "<group>"; };
|
||||
1AC3622416D47C5C000847F2 /* background.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; name = background.ogg; path = ../Resources/background.ogg; sourceTree = "<group>"; };
|
||||
1AC3622516D47C5C000847F2 /* crop.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = crop.png; path = ../Resources/crop.png; sourceTree = "<group>"; };
|
||||
|
@ -509,6 +512,7 @@
|
|||
F293BC4615EB859D00256477 /* Resources */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
15FFA0FC1894DDEF00C96D45 /* mobdebug.lua */,
|
||||
1AC3622316D47C5C000847F2 /* background.mp3 */,
|
||||
1AC3622416D47C5C000847F2 /* background.ogg */,
|
||||
1AC3622516D47C5C000847F2 /* crop.png */,
|
||||
|
@ -707,6 +711,7 @@
|
|||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
15A8A4711834C6AD00142BE0 /* DeprecatedEnum.lua in Resources */,
|
||||
15FFA0FE1894DDEF00C96D45 /* mobdebug.lua in Resources */,
|
||||
5023814817EBBCE400990C9B /* background.mp3 in Resources */,
|
||||
5023814917EBBCE400990C9B /* background.ogg in Resources */,
|
||||
5023814A17EBBCE400990C9B /* crop.png in Resources */,
|
||||
|
@ -769,6 +774,7 @@
|
|||
15A8A46A1834C6AD00142BE0 /* Cocos2dConstants.lua in Resources */,
|
||||
1AC3623616D47C5C000847F2 /* hello.lua in Resources */,
|
||||
5091733917ECE17A00D62437 /* Icon-58.png in Resources */,
|
||||
15FFA0FD1894DDEF00C96D45 /* mobdebug.lua in Resources */,
|
||||
15A8A4641834C6AD00142BE0 /* AudioEngine.lua in Resources */,
|
||||
1AC3623716D47C5C000847F2 /* hello2.lua in Resources */,
|
||||
1AC3623816D47C5C000847F2 /* land.png in Resources */,
|
||||
|
|
Loading…
Reference in New Issue