Merge pull request #5231 from samuele3hu/developBug

issue #3837:Add the debug support for mac and lua template
This commit is contained in:
James Chen 2014-01-25 23:40:10 -08:00
commit 603df24d0e
7 changed files with 1508 additions and 26 deletions

View File

@ -1 +1 @@
cb6829f533bf328c6df6cd510b92ae2a63725380 c958533394964fe0c38bd60c272a0b48ec38d9d6

View File

@ -31,7 +31,7 @@ extern "C" {
#include "lualib.h" #include "lualib.h"
#include "lauxlib.h" #include "lauxlib.h"
#include "tolua_fix.h" #include "tolua_fix.h"
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
#include "lua_extensions.h" #include "lua_extensions.h"
#endif #endif
} }
@ -149,7 +149,7 @@ bool LuaStack::init(void)
{NULL, NULL} {NULL, NULL}
}; };
luaL_register(_state, "_G", global_functions); luaL_register(_state, "_G", global_functions);
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
luaopen_lua_extensions(_state); luaopen_lua_extensions(_state);
#endif #endif
g_luaType.clear(); g_luaType.clear();

View File

@ -17,6 +17,13 @@ local function main()
collectgarbage("setpause", 100) collectgarbage("setpause", 100)
collectgarbage("setstepmul", 5000) 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" require "hello2"
cclog("result is " .. myadd(1, 1)) cclog("result is " .. myadd(1, 1))

View File

@ -17,6 +17,13 @@ local function main()
collectgarbage("setpause", 100) collectgarbage("setpause", 100)
collectgarbage("setstepmul", 5000) 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" require "hello2"
cclog("result is " .. myadd(1, 1)) cclog("result is " .. myadd(1, 1))
@ -103,43 +110,39 @@ local function main()
-- handing touch events -- handing touch events
local touchBeginPoint = nil local touchBeginPoint = nil
local function onTouchBegan(touch, event)
local function onTouchBegan(x, y) local location = touch:getLocation()
cclog("onTouchBegan: %0.2f, %0.2f", x, y) cclog("onTouchBegan: %0.2f, %0.2f", location.x, location.y)
touchBeginPoint = {x = x, y = y} touchBeginPoint = {x = location.x, y = location.y}
spriteDog.isPaused = true spriteDog.isPaused = true
-- CCTOUCHBEGAN event must return true -- CCTOUCHBEGAN event must return true
return true return true
end end
local function onTouchMoved(x, y) local function onTouchMoved(touch, event)
cclog("onTouchMoved: %0.2f, %0.2f", x, y) local location = touch:getLocation()
cclog("onTouchMoved: %0.2f, %0.2f", location.x, location.y)
if touchBeginPoint then if touchBeginPoint then
local cx, cy = layerFarm:getPosition() local cx, cy = layerFarm:getPosition()
layerFarm:setPosition(cx + x - touchBeginPoint.x, layerFarm:setPosition(cx + location.x - touchBeginPoint.x,
cy + y - touchBeginPoint.y) cy + location.y - touchBeginPoint.y)
touchBeginPoint = {x = x, y = y} touchBeginPoint = {x = location.x, y = location.y}
end end
end end
local function onTouchEnded(x, y) local function onTouchEnded(touch, event)
cclog("onTouchEnded: %0.2f, %0.2f", x, y) local location = touch:getLocation()
cclog("onTouchEnded: %0.2f, %0.2f", location.x, location.y)
touchBeginPoint = nil touchBeginPoint = nil
spriteDog.isPaused = false spriteDog.isPaused = false
end end
local function onTouch(eventType, x, y) local listener = cc.EventListenerTouchOneByOne:create()
if eventType == "began" then listener:registerScriptHandler(onTouchBegan,cc.Handler.EVENT_TOUCH_BEGAN )
return onTouchBegan(x, y) listener:registerScriptHandler(onTouchMoved,cc.Handler.EVENT_TOUCH_MOVED )
elseif eventType == "moved" then listener:registerScriptHandler(onTouchEnded,cc.Handler.EVENT_TOUCH_ENDED )
return onTouchMoved(x, y) local eventDispatcher = layerFarm:getEventDispatcher()
else eventDispatcher:addEventListenerWithSceneGraphPriority(listener, layerFarm)
return onTouchEnded(x, y)
end
end
layerFarm:registerScriptTouchHandler(onTouch)
layerFarm:setTouchEnabled(true)
return layerFarm return layerFarm
end end

File diff suppressed because it is too large Load Diff

View File

@ -32,4 +32,5 @@
android:normalScreens="true" android:normalScreens="true"
android:largeScreens="true" android:largeScreens="true"
android:xlargeScreens="true"/> android:xlargeScreens="true"/>
<uses-permission android:name="android.permission.INTERNET"/>
</manifest> </manifest>

View File

@ -55,6 +55,8 @@
15A8A4851834C73500142BE0 /* libCocosDenshion Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 15A8A41F1834BDA200142BE0 /* libCocosDenshion Mac.a */; }; 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 */; }; 15A8A4861834C73500142BE0 /* libluabindings Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 15A8A4231834BDA200142BE0 /* libluabindings Mac.a */; };
15A8A4881834C90F00142BE0 /* libcurl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 15A8A4871834C90E00142BE0 /* libcurl.dylib */; }; 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 */; }; 1AC3622F16D47C5C000847F2 /* background.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = 1AC3622316D47C5C000847F2 /* background.mp3 */; };
1AC3623016D47C5C000847F2 /* background.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 1AC3622416D47C5C000847F2 /* background.ogg */; }; 1AC3623016D47C5C000847F2 /* background.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 1AC3622416D47C5C000847F2 /* background.ogg */; };
1AC3623116D47C5C000847F2 /* crop.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AC3622516D47C5C000847F2 /* crop.png */; }; 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>"; }; 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; }; 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>"; }; 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>"; }; 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>"; }; 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>"; }; 1AC3622516D47C5C000847F2 /* crop.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = crop.png; path = ../Resources/crop.png; sourceTree = "<group>"; };
@ -509,6 +512,7 @@
F293BC4615EB859D00256477 /* Resources */ = { F293BC4615EB859D00256477 /* Resources */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
15FFA0FC1894DDEF00C96D45 /* mobdebug.lua */,
1AC3622316D47C5C000847F2 /* background.mp3 */, 1AC3622316D47C5C000847F2 /* background.mp3 */,
1AC3622416D47C5C000847F2 /* background.ogg */, 1AC3622416D47C5C000847F2 /* background.ogg */,
1AC3622516D47C5C000847F2 /* crop.png */, 1AC3622516D47C5C000847F2 /* crop.png */,
@ -707,6 +711,7 @@
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
15A8A4711834C6AD00142BE0 /* DeprecatedEnum.lua in Resources */, 15A8A4711834C6AD00142BE0 /* DeprecatedEnum.lua in Resources */,
15FFA0FE1894DDEF00C96D45 /* mobdebug.lua in Resources */,
5023814817EBBCE400990C9B /* background.mp3 in Resources */, 5023814817EBBCE400990C9B /* background.mp3 in Resources */,
5023814917EBBCE400990C9B /* background.ogg in Resources */, 5023814917EBBCE400990C9B /* background.ogg in Resources */,
5023814A17EBBCE400990C9B /* crop.png in Resources */, 5023814A17EBBCE400990C9B /* crop.png in Resources */,
@ -769,6 +774,7 @@
15A8A46A1834C6AD00142BE0 /* Cocos2dConstants.lua in Resources */, 15A8A46A1834C6AD00142BE0 /* Cocos2dConstants.lua in Resources */,
1AC3623616D47C5C000847F2 /* hello.lua in Resources */, 1AC3623616D47C5C000847F2 /* hello.lua in Resources */,
5091733917ECE17A00D62437 /* Icon-58.png in Resources */, 5091733917ECE17A00D62437 /* Icon-58.png in Resources */,
15FFA0FD1894DDEF00C96D45 /* mobdebug.lua in Resources */,
15A8A4641834C6AD00142BE0 /* AudioEngine.lua in Resources */, 15A8A4641834C6AD00142BE0 /* AudioEngine.lua in Resources */,
1AC3623716D47C5C000847F2 /* hello2.lua in Resources */, 1AC3623716D47C5C000847F2 /* hello2.lua in Resources */,
1AC3623816D47C5C000847F2 /* land.png in Resources */, 1AC3623816D47C5C000847F2 /* land.png in Resources */,