Add Scene3DTest.

This commit is contained in:
Vincent Yang 2015-05-07 16:22:30 +08:00
parent c785b7a021
commit a8f0ad9d68
5 changed files with 144 additions and 1 deletions

View File

@ -816,6 +816,8 @@
A07A52BF1783AF210073F6A7 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52B91783AE900073F6A7 /* OpenGLES.framework */; };
A07A52C01783AF250073F6A7 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52B71783AE6D0073F6A7 /* UIKit.framework */; };
A07A52C31783B02C0073F6A7 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52C11783B01F0073F6A7 /* AVFoundation.framework */; };
A0BD49FE1AFAFEE50046CCE3 /* Scene3DTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A0BD49FC1AFAFEE50046CCE3 /* Scene3DTest.cpp */; };
A0BD49FF1AFAFEE50046CCE3 /* Scene3DTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A0BD49FC1AFAFEE50046CCE3 /* Scene3DTest.cpp */; };
A5030C3519D059DA000E78E7 /* OpenURLTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5030C3319D059DA000E78E7 /* OpenURLTest.cpp */; };
A5030C3619D059DA000E78E7 /* OpenURLTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5030C3319D059DA000E78E7 /* OpenURLTest.cpp */; };
B2507B6B192589AF00FA4972 /* Shaders3D in Resources */ = {isa = PBXBuildFile; fileRef = B2507B6A192589AF00FA4972 /* Shaders3D */; };
@ -1761,6 +1763,8 @@
A07A52B91783AE900073F6A7 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk/System/Library/Frameworks/OpenGLES.framework; sourceTree = DEVELOPER_DIR; };
A07A52BB1783AEB80073F6A7 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk/System/Library/Frameworks/CoreGraphics.framework; sourceTree = DEVELOPER_DIR; };
A07A52C11783B01F0073F6A7 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk/System/Library/Frameworks/AVFoundation.framework; sourceTree = DEVELOPER_DIR; };
A0BD49FC1AFAFEE50046CCE3 /* Scene3DTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Scene3DTest.cpp; sourceTree = "<group>"; };
A0BD49FD1AFAFEE50046CCE3 /* Scene3DTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Scene3DTest.h; sourceTree = "<group>"; };
A5030C3319D059DA000E78E7 /* OpenURLTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OpenURLTest.cpp; path = OpenURLTest/OpenURLTest.cpp; sourceTree = "<group>"; };
A5030C3419D059DA000E78E7 /* OpenURLTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OpenURLTest.h; path = OpenURLTest/OpenURLTest.h; sourceTree = "<group>"; };
B2507B6A192589AF00FA4972 /* Shaders3D */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Shaders3D; path = "../tests/cpp-tests/Resources/Shaders3D"; sourceTree = "<group>"; };
@ -2248,6 +2252,7 @@
1AC35ADD18CECF0C00F37B72 /* ReleasePoolTest */,
1AC35AE018CECF0C00F37B72 /* RenderTextureTest */,
1AC35AE318CECF0C00F37B72 /* RotateWorldTest */,
A0BD49FB1AFAFEE50046CCE3 /* Scene3DTest */,
1AC35AE618CECF0C00F37B72 /* SceneTest */,
1AC35AE918CECF0C00F37B72 /* SchedulerTest */,
1AC35AEC18CECF0C00F37B72 /* ShaderTest */,
@ -3969,6 +3974,15 @@
path = SpritePolygonTest;
sourceTree = "<group>";
};
A0BD49FB1AFAFEE50046CCE3 /* Scene3DTest */ = {
isa = PBXGroup;
children = (
A0BD49FC1AFAFEE50046CCE3 /* Scene3DTest.cpp */,
A0BD49FD1AFAFEE50046CCE3 /* Scene3DTest.h */,
);
path = Scene3DTest;
sourceTree = "<group>";
};
A5030C3219D059AB000E78E7 /* OpenURLTest */ = {
isa = PBXGroup;
children = (
@ -4932,6 +4946,7 @@
1AC35C0918CECF0C00F37B72 /* IntervalTest.cpp in Sources */,
29080DA5191B595E0066F8DF /* UIButtonTest_Editor.cpp in Sources */,
29080DC3191B595E0066F8DF /* UIScene.cpp in Sources */,
A0BD49FE1AFAFEE50046CCE3 /* Scene3DTest.cpp in Sources */,
29080D9B191B595E0066F8DF /* CustomParticleWidget.cpp in Sources */,
29080D8D191B595E0066F8DF /* CocosGUIScene.cpp in Sources */,
5EBEECB01995247000429821 /* DrawNode3D.cpp in Sources */,
@ -5079,6 +5094,7 @@
1AC35C6018CECF0C00F37B72 /* Paddle.cpp in Sources */,
29080DBE191B595E0066F8DF /* UIPageViewTest.cpp in Sources */,
1AC35BDC18CECF0C00F37B72 /* SceneEditorTest.cpp in Sources */,
A0BD49FF1AFAFEE50046CCE3 /* Scene3DTest.cpp in Sources */,
A5030C3619D059DA000E78E7 /* OpenURLTest.cpp in Sources */,
1AC35B4C18CECF0C00F37B72 /* BugsTest.cpp in Sources */,
1AC35C5218CECF0C00F37B72 /* testBasic.cpp in Sources */,

View File

@ -0,0 +1,117 @@
#include "Scene3DTest.h"
#include "../testResource.h"
USING_NS_CC;
////////////////////////////////////////////////////////////////////////////////
// Implements Scene3DTestScene
class Scene3DTestScene : public TestCase
{
public:
CREATE_FUNC(Scene3DTestScene);
private:
Scene3DTestScene();
virtual ~Scene3DTestScene();
bool init() override;
void create3DWorld();
void createUI();
void createDialog();
Node* _ui;
Node* _dialog;
};
#define GAME_3D_MASK CameraFlag::DEFAULT
#define GAME_UI_MASK CameraFlag::USER1
#define GAME_DIALOG_MASK CameraFlag::USER2
#define GAME_UI_ZORDER 1
#define GAME_DIALOG_ZORDER 2
Scene3DTestScene::Scene3DTestScene()
: _dialog(nullptr)
{
}
Scene3DTestScene::~Scene3DTestScene()
{
CC_SAFE_RELEASE(_dialog);
}
bool Scene3DTestScene::init()
{
bool ret = false;
do
{
CC_BREAK_IF(false == TestCase::init());
Director::getInstance()->setDisplayStats(false);
create3DWorld();
createUI();
createDialog();
ret = true;
} while (0);
return ret;
}
void Scene3DTestScene::create3DWorld()
{
std::string filename = "Sprite3DTest/girl.c3b";
auto girl = Sprite3D::create(filename);
girl->setPosition(240, 0);
this->addChild(girl);
}
void Scene3DTestScene::createUI()
{
auto closeItem = MenuItemImage::create(s_pathClose, s_pathClose, [this](Ref* sender){
this->_dialog->setVisible(!this->_dialog->isVisible());
});
closeItem->setPosition(240 + 20, 160);
auto menu = Menu::create(closeItem, nullptr);
menu->setPosition(Vec2::ZERO);
menu->setCameraMask((unsigned short)GAME_UI_MASK, true);
this->addChild(menu, GAME_UI_ZORDER);
_ui = menu;
auto uiCamera = Camera::create();
// uiCamera->setPositionX(uiCamera->getPositionX() + 50);
uiCamera->setCameraFlag(GAME_UI_MASK);
this->addChild(uiCamera);
}
void Scene3DTestScene::createDialog()
{
if (_dialog) {
return;
}
auto layer = LayerColor::create(Color4B(166, 166, 166, 255), 240, 160);
layer->setPosition(120, 80);
//layer->setVisible(false);
auto title = Label::createWithTTF("Actor Dialog","fonts/arial.ttf",16);
title->setPosition(120, 140);
layer->addChild(title);
std::string filename = "Sprite3DTest/girl.c3b";
auto girl = Sprite3D::create(filename);
girl->setScale(0.5);
girl->setPosition(100, -20);
layer->addChild(girl);
this->addChild(layer, GAME_DIALOG_ZORDER);
_dialog = layer;
}
////////////////////////////////////////////////////////////////////////////////
// Implements Scene3DTests
Scene3DTests::Scene3DTests()
{
ADD_TEST_CASE(Scene3DTestScene);
}

View File

@ -0,0 +1,8 @@
#ifndef _SCENE_3D_TEST_H_
#define _SCENE_3D_TEST_H_
#include "../BaseTest.h"
DEFINE_TEST_SUITE(Scene3DTests);
#endif

View File

@ -16,6 +16,7 @@ class RootTests : public TestList
public:
RootTests()
{
addTest("Node: Scene3D", [](){return new (std::nothrow) Scene3DTests(); });
addTest("SpritePolygon", [](){return new (std::nothrow) SpritePolygonTest(); });
addTest("ActionManager", [](){return new (std::nothrow) ActionManagerTests(); });
addTest("Actions - Basic", [](){ return new (std::nothrow) ActionsTests(); });
@ -96,7 +97,7 @@ TestController::TestController()
, _isRunInBackground(false)
, _testSuite(nullptr)
{
_rootTestList = new (std::nothrow) RootTests;
_rootTestList = new (std::nothrow) RootTests;
_rootTestList->runThisTest();
_director = Director::getInstance();

View File

@ -20,6 +20,7 @@
#include "MenuTest/MenuTest.h"
#include "ActionManagerTest/ActionManagerTest.h"
#include "LayerTest/LayerTest.h"
#include "Scene3DTest/Scene3DTest.h"
#include "SceneTest/SceneTest.h"
#include "ParallaxTest/ParallaxTest.h"
#include "TileMapTest/TileMapTest.h"