Merge remote-tracking branch 'upstream/master'

This commit is contained in:
yodesoft 2013-04-07 21:12:07 +08:00
commit 8f4b04aef7
7 changed files with 223 additions and 250 deletions

View File

@ -0,0 +1,47 @@
local function CurrentLanguageTest()
local ret = CCLayer:create()
local label = CCLabelTTF:create("Current language Test", "Arial", 28)
ret:addChild(label, 0)
label:setPosition( ccp(VisibleRect:center().x, VisibleRect:top().y-50) )
local labelLanguage = CCLabelTTF:create("", "Arial", 20)
labelLanguage:setPosition(VisibleRect:center())
local currentLanguageType = CCApplication:sharedApplication():getCurrentLanguage()
if currentLanguageType == kLanguageEnglish then
labelLanguage:setString("current language is English")
elseif currentLanguageType == kLanguageChinese then
labelLanguage:setString("current language is Chinese")
elseif currentLanguageType == kLanguageFrench then
labelLanguage:setString("current language is French")
elseif currentLanguageType == kLanguageGerman then
labelLanguage:setString("current language is German")
elseif currentLanguageType == kLanguageItalian then
labelLanguage:setString("current language is Italian")
elseif currentLanguageType == kLanguageRussian then
labelLanguage:setString("current language is Russian")
elseif currentLanguageType == kLanguageSpanish then
labelLanguage:setString("current language is Spanish")
elseif currentLanguageType == kLanguageKorean then
labelLanguage:setString("current language is Korean")
elseif currentLanguageType == kLanguageJapanese then
labelLanguage:setString("current language is Japanese")
elseif currentLanguageType == kLanguageHungarian then
labelLanguage:setString("current language is Hungarian")
elseif currentLanguageType == kLanguagePortuguese then
labelLanguage:setString("current language is Portuguese")
elseif currentLanguageType == kLanguageArabic then
labelLanguage:setString("current language is Arabic")
end
ret:addChild(labelLanguage)
return ret
end
function CurrentLanguageTestMain()
local scene = CCScene:create()
local pLayer = CurrentLanguageTest()
scene:addChild(pLayer)
scene:addChild(CreateBackMenuItem())
return scene
end

View File

@ -0,0 +1,80 @@
-- enable log
local function doTest()
cclog("********************** init value ***********************")
-- set default value
CCUserDefault:sharedUserDefault():setStringForKey("string", "value1")
CCUserDefault:sharedUserDefault():setIntegerForKey("integer", 10)
CCUserDefault:sharedUserDefault():setFloatForKey("float", 2.3)
CCUserDefault:sharedUserDefault():setDoubleForKey("double", 2.4)
CCUserDefault:sharedUserDefault():setBoolForKey("bool", true)
-- print value
local ret = CCUserDefault:sharedUserDefault():getStringForKey("string")
cclog("string is %s", ret)
local d = CCUserDefault:sharedUserDefault():getDoubleForKey("double")
cclog("double is %f", d)
local i = CCUserDefault:sharedUserDefault():getIntegerForKey("integer")
cclog("integer is %d", i)
local f = CCUserDefault:sharedUserDefault():getFloatForKey("float")
cclog("float is %f", f)
local b = CCUserDefault:sharedUserDefault():getBoolForKey("bool")
if b == true then
cclog("bool is true")
else
cclog("bool is false")
end
--CCUserDefault:sharedUserDefault():flush()
cclog("********************** after change value ***********************")
-- change the value
CCUserDefault:sharedUserDefault():setStringForKey("string", "value2")
CCUserDefault:sharedUserDefault():setIntegerForKey("integer", 11)
CCUserDefault:sharedUserDefault():setFloatForKey("float", 2.5)
CCUserDefault:sharedUserDefault():setDoubleForKey("double", 2.6)
CCUserDefault:sharedUserDefault():setBoolForKey("bool", false)
CCUserDefault:sharedUserDefault():flush()
-- print value
ret = CCUserDefault:sharedUserDefault():getStringForKey("string")
cclog("string is %s", ret)
d = CCUserDefault:sharedUserDefault():getDoubleForKey("double")
cclog("double is %f", d)
i = CCUserDefault:sharedUserDefault():getIntegerForKey("integer")
cclog("integer is %d", i)
f = CCUserDefault:sharedUserDefault():getFloatForKey("float")
cclog("float is %f", f)
b = CCUserDefault:sharedUserDefault():getBoolForKey("bool")
if b == true then
cclog("bool is true")
else
cclog("bool is false")
end
end
function UserDefaultTestMain()
local ret = CCScene:create()
local s = CCDirector:sharedDirector():getWinSize()
local label = CCLabelTTF:create("CCUserDefault test see log", "Arial", 28)
ret:addChild(label, 0)
label:setPosition( ccp(s.width/2, s.height-50) )
doTest()
return ret
end

View File

@ -1,6 +1,36 @@
require "luaScript/tests"
require "luaScript/helper" require "luaScript/helper"
require "luaScript/testResource" require "luaScript/testResource"
require "luaScript/ActionsTest/ActionsTest"
require "luaScript/TransitionsTest/TransitionsTest"
require "luaScript/ActionsProgressTest/ActionsProgressTest"
require "luaScript/EffectsTest/EffectsTest"
require "luaScript/ClickAndMoveTest/ClickAndMoveTest"
require "luaScript/RotateWorldTest/RotateWorldTest"
require "luaScript/ParticleTest/ParticleTest"
require "luaScript/ActionsEaseTest/ActionsEaseTest"
require "luaScript/MotionStreakTest/MotionStreakTest"
require "luaScript/DrawPrimitivesTest/DrawPrimitivesTest"
require "luaScript/NodeTest/NodeTest"
require "luaScript/TouchesTest/TouchesTest"
require "luaScript/SpriteTest/SpriteTest"
require "luaScript/LayerTest/LayerTest"
require "luaScript/PerformanceTest/PerformanceTest"
require "luaScript/LabelTest/LabelTest"
require "luaScript/ParallaxTest/ParallaxTest"
require "luaScript/TileMapTest/TileMapTest"
require "luaScript/ActionManagerTest/ActionManagerTest"
require "luaScript/MenuTest/MenuTest"
require "luaScript/IntervalTest/IntervalTest"
require "luaScript/SceneTest/SceneTest"
require "luaScript/Texture2dTest/Texture2dTest"
require "luaScript/RenderTextureTest/RenderTextureTest"
require "luaScript/ZwoptexTest/ZwoptexTest"
require "luaScript/FontTest/FontTest"
require "luaScript/CocosDenshionTest/CocosDenshionTest"
require "luaScript/EffectsAdvancedTest/EffectsAdvancedTest"
require "luaScript/UserDefaultTest/UserDefaultTest"
require "luaScript/CurrentLanguageTest/CurrentLanguageTest"
------------------------ ------------------------
@ -9,120 +39,61 @@ local LINE_SPACE = 40
local CurPos = {x = 0, y = 0} local CurPos = {x = 0, y = 0}
local BeginPos = {x = 0, y = 0} local BeginPos = {x = 0, y = 0}
local _allTests = {
{ isSupported = true, name = "ActionsTest" , create_func = ActionsTest },
{ isSupported = true, name = "TransitionsTest" , create_func = TransitionsTest },
{ isSupported = true, name = "ActionsProgressTest" , create_func = ProgressActionsTest },
{ isSupported = true, name = "EffectsTest" , create_func = EffectsTest },
{ isSupported = true, name = "ClickAndMoveTest" , create_func = ClickAndMoveTest },
{ isSupported = true, name = "RotateWorldTest" , create_func = RotateWorldTest },
{ isSupported = true, name = "ParticleTest" , create_func = ParticleTest },
{ isSupported = true, name = "ActionsEaseTest" , create_func = EaseActionsTest },
{ isSupported = true, name = "MotionStreakTest" , create_func = MotionStreakTest },
{ isSupported = false, name = "DrawPrimitivesTest" , create_func= DrawPrimitivesTest },
{ isSupported = true, name = "NodeTest" , create_func = CocosNodeTest },
{ isSupported = true, name = "TouchesTest" , create_func = TouchesTest },
{ isSupported = true, name = "MenuTest" , create_func = MenuTestMain },
{ isSupported = true, name = "ActionManagerTest" , create_func = ActionManagerTestMain },
{ isSupported = true, name = "LayerTest" , create_func = LayerTestMain },
{ isSupported = true, name = "SceneTest" , create_func = SceneTestMain },
{ isSupported = true, name = "ParallaxTest" , create_func = ParallaxTestMain },
{ isSupported = true, name = "TileMapTest" , create_func = TileMapTestMain },
{ isSupported = true, name = "IntervalTest" , create_func = IntervalTestMain },
{ isSupported = false, name = "ChipmunkAccelTouchTest" , create_func= ChipmunkAccelTouchTestMain },
{ isSupported = true, name = "LabelTest" , create_func = LabelTest },
{ isSupported = false, name = "TextInputTest" , create_func= TextInputTestMain },
{ isSupported = true, name = "SpriteTest" , create_func = SpriteTest },
{ isSupported = false, name = "SchdulerTest" , create_func= SchdulerTestMain },
{ isSupported = true, name = "RenderTextureTest" , create_func = RenderTextureTestMain },
{ isSupported = true, name = "Texture2DTest" , create_func = Texture2dTestMain },
{ isSupported = false, name = "Box2dTest" , create_func= Box2dTestMain },
{ isSupported = false, name = "Box2dTestBed" , create_func= Box2dTestBedMain },
{ isSupported = true, name = "EffectAdvancedTest" , create_func = EffectAdvancedTestMain },
{ isSupported = false, name = "Accelerometer" , create_func= AccelerometerMain },
{ isSupported = false, name = "KeypadTest" , create_func= KeypadTestMain },
{ isSupported = true, name = "CocosDenshionTest" , create_func = CocosDenshionTestMain },
{ isSupported = false, name = "PerformanceTest" , create_func= PerformanceTestMain },
{ isSupported = true, name = "ZwoptexTest" , create_func = ZwoptexTestMain },
{ isSupported = false, name = "CurlTest" , create_func= CurlTestMain },
{ isSupported = true, name = "UserDefaultTest" , create_func= UserDefaultTestMain },
{ isSupported = false, name = "BugsTest" , create_func= BugsTestMain },
{ isSupported = true, name = "FontTest" , create_func = FontTestMain },
{ isSupported = true, name = "CurrentLanguageTest" , create_func= CurrentLanguageTestMain },
{ isSupported = false, name = "TextureCacheTest" , create_func= TextureCacheTestMain },
{ isSupported = false, name = "ExtensionsTest" , create_func= ExtensionsTestMain },
{ isSupported = false, name = "ShaderTest" , create_func= ShaderTestMain },
{ isSupported = false, name = "MutiTouchTest" , create_func= MutiTouchTestMain }
}
local TESTS_COUNT = table.getn(_allTests)
-- create scene -- create scene
local function CreateTestScene(nIdx) local function CreateTestScene(nIdx)
local scene = _allTests[nIdx].create_func()
CCDirector:sharedDirector():purgeCachedData() CCDirector:sharedDirector():purgeCachedData()
local scene = nil
if nIdx == Test_Table.TEST_ACTIONS then
scene = ActionsTest()
elseif nIdx == Test_Table.TEST_TRANSITIONS then
scene = TransitionsTest()
elseif nIdx == Test_Table.TEST_PROGRESS_ACTIONS then
scene = ProgressActionsTest()
elseif nIdx == Test_Table.TEST_EFFECTS then
scene = EffectsTest()
elseif nIdx == Test_Table.TEST_CLICK_AND_MOVE then
scene = ClickAndMoveTest()
elseif nIdx == Test_Table.TEST_ROTATE_WORLD then
scene = RotateWorldTest()
elseif nIdx == Test_Table.TEST_PARTICLE then
scene = ParticleTest()
elseif nIdx == Test_Table.TEST_EASE_ACTIONS then
scene = EaseActionsTest()
elseif nIdx == Test_Table.TEST_MOTION_STREAK then
scene = MotionStreakTest()
elseif nIdx == Test_Table.TEST_DRAW_PRIMITIVES then
scene = DrawPrimitivesTest()
elseif nIdx == Test_Table.TEST_COCOSNODE then
scene = CocosNodeTest()
elseif nIdx == Test_Table.TEST_TOUCHES then
scene = TouchesTest()
elseif nIdx == Test_Table.TEST_MENU then
scene = MenuTestMain()
elseif nIdx == Test_Table.TEST_ACTION_MANAGER then
scene = ActionManagerTestMain()
elseif nIdx == Test_Table.TEST_LAYER then
scene = LayerTestMain()
elseif nIdx == Test_Table.TEST_SCENE then
scene = SceneTestMain()
elseif nIdx == Test_Table.TEST_PARALLAX then
scene = ParallaxTestMain()
elseif nIdx == Test_Table.TEST_TILE_MAP then
scene = TileMapTestMain()
elseif nIdx == Test_Table.TEST_INTERVAL then
scene = IntervalTestMain()
elseif nIdx == Test_Table.TEST_CHIPMUNKACCELTOUCH then
--#if (CC_TARGET_PLATFORM != CC_PLATFORM_MARMALADE)
-- pScene = new ChipmunkAccelTouchTestScene()
--#else
--#ifdef MARMALADEUSECHIPMUNK
--#if (MARMALADEUSECHIPMUNK == 1)
-- pScene = new ChipmunkAccelTouchTestScene();
--#endif
-- break;
--#endif
--#endif
elseif nIdx == Test_Table.TEST_LABEL then
scene = LabelTest()
elseif nIdx == Test_Table.TEST_TEXT_INPUT then
elseif nIdx == Test_Table.TEST_SPRITE then
scene = SpriteTest()
elseif nIdx == Test_Table.TEST_SCHEDULER then
elseif nIdx == Test_Table.TEST_RENDERTEXTURE then
scene = RenderTextureTestMain()
elseif nIdx == Test_Table.TEST_TEXTURE2D then
scene = Texture2dTestMain()
elseif nIdx == Test_Table.TEST_BOX2D then
elseif nIdx == Test_Table.TEST_BOX2DBED then
elseif nIdx == Test_Table.TEST_EFFECT_ADVANCE then
scene = EffectAdvancedTestMain()
elseif nIdx == Test_Table.TEST_ACCELEROMRTER then
--#if (CC_TARGET_PLATFORM != CC_PLATFORM_BADA)
-- elseif nIdx == Test_Table.TEST_KEYPAD then
-- pScene = new KeypadTestScene()
--#endif
elseif nIdx == Test_Table.TEST_COCOSDENSHION then
scene = CocosDenshionTestMain()
elseif nIdx == Test_Table.TEST_PERFORMANCE then
scene = PerformanceTest()
elseif nIdx == Test_Table.TEST_ZWOPTEX then
scene = ZwoptexTestMain()
--#if (CC_TARGET_PLATFORM != CC_PLATFORM_MARMALADE)
-- bada don't support libcurl
--#if (CC_TARGET_PLATFORM != CC_PLATFORM_BADA)
-- elseif nIdx == Test_Table.TEXT_CURL then
--#endif
--#endif
elseif nIdx == Test_Table.TEST_USERDEFAULT then
elseif nIdx == Test_Table.TEST_BUGS then
elseif nIdx == Test_Table.TEST_FONTS then
scene = FontTestMain()
elseif nIdx == Test_Table.TEST_CURRENT_LANGUAGE then
--#if (CC_TARGET_PLATFORM != CC_PLATFORM_MARMALADE)
-- elseif nIdx == Test_Table.TEST_TEXTURECACHE then pScene = new TextureCacheTestScene()
--#endif
elseif nIdx == Test_Table.TEST_EXTENSIONS then
elseif nIdx == Test_Table.TEST_SHADER then
elseif nIdx == Test_Table.TEST_MUTITOUCH then
end
return scene return scene
end end
-- create menu -- create menu
function CreateTestMenu() function CreateTestMenu()
local menuLayer = CCLayer:create() local menuLayer = CCLayer:create()
@ -153,16 +124,20 @@ function CreateTestMenu()
-- add menu items for tests -- add menu items for tests
local MainMenu = CCMenu:create() local MainMenu = CCMenu:create()
for index, labelName in pairs(Test_Name) do local index = 0
local testLabel = CCLabelTTF:create(labelName, "Arial", 24) local obj = nil
for index, obj in pairs(_allTests) do
local testLabel = CCLabelTTF:create(obj.name, "Arial", 24)
local testMenuItem = CCMenuItemLabel:create(testLabel) local testMenuItem = CCMenuItemLabel:create(testLabel)
if not obj.isSupported then
testMenuItem:setEnabled(false)
end
testMenuItem:registerScriptTapHandler(menuCallback) testMenuItem:registerScriptTapHandler(menuCallback)
testMenuItem:setPosition(ccp(s.width / 2, (s.height - (index + 1) * LINE_SPACE))) testMenuItem:setPosition(ccp(s.width / 2, (s.height - (index) * LINE_SPACE)))
MainMenu:addChild(testMenuItem, index + 10000, index + 10000) MainMenu:addChild(testMenuItem, index + 10000, index + 10000)
end end
MainMenu:setContentSize(CCSizeMake(s.width, (Test_Table.TESTS_COUNT + 1) * (LINE_SPACE))) MainMenu:setContentSize(CCSizeMake(s.width, (TESTS_COUNT + 1) * (LINE_SPACE)))
MainMenu:setPosition(CurPos.x, CurPos.y) MainMenu:setPosition(CurPos.x, CurPos.y)
menuLayer:addChild(MainMenu) menuLayer:addChild(MainMenu)
@ -183,8 +158,8 @@ function CreateTestMenu()
return return
end end
if nextPosy > ((Test_Table.TESTS_COUNT + 1) * LINE_SPACE - winSize.height) then if nextPosy > ((TESTS_COUNT + 1) * LINE_SPACE - winSize.height) then
MainMenu:setPosition(0, ((Test_Table.TESTS_COUNT + 1) * LINE_SPACE - winSize.height)) MainMenu:setPosition(0, ((TESTS_COUNT + 1) * LINE_SPACE - winSize.height))
return return
end end

View File

@ -1,129 +0,0 @@
require "luaScript/helper"
require "luaScript/ActionsTest/ActionsTest"
require "luaScript/TransitionsTest/TransitionsTest"
require "luaScript/ActionsProgressTest/ActionsProgressTest"
require "luaScript/EffectsTest/EffectsTest"
require "luaScript/ClickAndMoveTest/ClickAndMoveTest"
require "luaScript/RotateWorldTest/RotateWorldTest"
require "luaScript/ParticleTest/ParticleTest"
require "luaScript/ActionsEaseTest/ActionsEaseTest"
require "luaScript/MotionStreakTest/MotionStreakTest"
require "luaScript/DrawPrimitivesTest/DrawPrimitivesTest"
require "luaScript/NodeTest/NodeTest"
require "luaScript/TouchesTest/TouchesTest"
require "luaScript/SpriteTest/SpriteTest"
require "luaScript/LayerTest/LayerTest"
require "luaScript/PerformanceTest/PerformanceTest"
require "luaScript/LabelTest/LabelTest"
require "luaScript/ParallaxTest/ParallaxTest"
require "luaScript/TileMapTest/TileMapTest"
require "luaScript/ActionManagerTest/ActionManagerTest"
require "luaScript/MenuTest/MenuTest"
require "luaScript/IntervalTest/IntervalTest"
require "luaScript/SceneTest/SceneTest"
require "luaScript/Texture2dTest/Texture2dTest"
require "luaScript/RenderTextureTest/RenderTextureTest"
require "luaScript/ZwoptexTest/ZwoptexTest"
require "luaScript/FontTest/FontTest"
require "luaScript/CocosDenshionTest/CocosDenshionTest"
require "luaScript/EffectsAdvancedTest/EffectsAdvancedTest"
----------------------------------------------------
-- tests scene
Test_Table =
{
"TEST_ACTIONS",
"TEST_TRANSITIONS",
"TEST_PROGRESS_ACTIONS",
"TEST_EFFECTS",
"TEST_CLICK_AND_MOVE",
"TEST_ROTATE_WORLD",
"TEST_PARTICLE",
"TEST_EASE_ACTIONS",
"TEST_MOTION_STREAK",
-- "TEST_DRAW_PRIMITIVES",
"TEST_COCOSNODE",
"TEST_TOUCHES",
"TEST_MENU",
"TEST_ACTION_MANAGER",
"TEST_LAYER",
"TEST_SCENE",
"TEST_PARALLAX",
"TEST_TILE_MAP",
"TEST_INTERVAL",
-- "TEST_CHIPMUNKACCELTOUCH",
"TEST_LABEL",
-- "TEST_TEXT_INPUT",
"TEST_SPRITE",
-- "TEST_SCHEDULER",
"TEST_RENDERTEXTURE",
"TEST_TEXTURE2D",
-- "TEST_BOX2D",
-- "TEST_BOX2DBED",
"TEST_EFFECT_ADVANCE",
-- "TEST_ACCELEROMRTER",
-- "TEST_KEYPAD",
"TEST_COCOSDENSHION",
-- "TEST_PERFORMANCE",
"TEST_ZWOPTEX",
-- "TEST_CURL",
-- "TEST_USERDEFAULT",
-- "TEST_BUGS",
"TEST_FONTS",
-- "TEST_CURRENT_LANGUAGE",
-- "TEST_TEXTURECACHE",
-- "TEST_EXTENSIONS",
-- "TEST_SHADER",
-- "TEST_MUTITOUCH",
"TESTS_COUNT"
}
Test_Table = CreateEnumTable(Test_Table)
Test_Name =
{
[0] = "ActionsTest",
"TransitionsTest",
"ActionsProgressTest",
"EffectsTest",
"ClickAndMoveTest",
"RotateWorldTest",
"ParticleTest",
"ActionsEaseTest",
"MotionStreakTest",
-- "DrawPrimitivesTest",
"NodeTest",
"TouchesTest",
"MenuTest",
"ActionManagerTest",
"LayerTest",
"SceneTest",
"ParallaxTest",
"TileMapTest",
"IntervalTest",
-- "ChipmunkAccelTouchTest",
"LabelTest",
-- "TextInputTest",
"SpriteTest",
-- "SchdulerTest",
"RenderTextureTest",
"Texture2DTest",
-- "Box2dTest",
-- "Box2dTestBed",
"EffectAdvancedTest",
-- "Accelerometer",
-- "KeypadTest",
"CocosDenshionTest",
-- "PerformanceTest",
"ZwoptexTest",
-- "CurlTest",
-- "UserDefaultTest",
-- "BugsTest",
"FontTest",
-- "CurrentLanguageTest",
-- "TextureCacheTest",
-- "ExtensionsTest",
-- "ShaderTest",
-- "MutiTouchTest"
}

View File

@ -124,7 +124,6 @@ void* cocos_main(void* arg)
"zwoptex/grossini.png", "zwoptex/grossini.png",
"luaScript/mainMenu.lua", "luaScript/mainMenu.lua",
"luaScript/helper.lua", "luaScript/helper.lua",
"luaScript/tests.lua",
"luaScript/testResource.lua", "luaScript/testResource.lua",
"luaScript/ActionsTest/ActionsTest.lua", "luaScript/ActionsTest/ActionsTest.lua",
"luaScript/ActionsTest/ActionsName.lua", "luaScript/ActionsTest/ActionsName.lua",

View File

@ -1 +1 @@
2616adaaf5ef1c788148f07aa3e04b87987a67b1 bc76dfef9a8f80745261d850ff9742dc48aa714e

View File

@ -1,4 +1,3 @@
typedef enum LanguageType typedef enum LanguageType
{ {
kLanguageEnglish = 0, kLanguageEnglish = 0,
@ -10,7 +9,9 @@ typedef enum LanguageType
kLanguageRussian, kLanguageRussian,
kLanguageKorean, kLanguageKorean,
kLanguageJapanese, kLanguageJapanese,
kLanguageHungarian kLanguageHungarian,
kLanguagePortuguese,
kLanguageArabic
} ccLanguageType; } ccLanguageType;
enum TargetPlatform enum TargetPlatform