PuzzleSDK
TerrainTest.h
浏览该文件的文档.
1/****************************************************************************
2 Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
3
4 http://www.cocos2d-x.org
5
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 THE SOFTWARE.
23 ****************************************************************************/
24
25#ifndef TERRAIN_TESH_H
26
27#include "../BaseTest.h"
28
29#include "3d/CCSprite3D.h"
30#include "3d/CCTerrain.h"
31#include "2d/CCCamera.h"
32#include "2d/CCAction.h"
33
34DEFINE_TEST_SUITE(TerrainTests);
35
37{
38protected:
39 std::string _title;
40};
41
43{
44public:
47 virtual std::string title() const override;
48 virtual std::string subtitle() const override;
49 void onTouchesMoved(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event* event);
50 cocos2d::Terrain* _terrain;
51protected:
52 cocos2d::Camera* _camera;
53};
54
55#define PLAYER_STATE_LEFT 0
56#define PLAYER_STATE_RIGHT 1
57#define PLAYER_STATE_IDLE 2
58#define PLAYER_STATE_FORWARD 3
59#define PLAYER_STATE_BACKWARD 4
60
61class Player : public cocos2d::Sprite3D
62{
63public:
64 static Player * create(const char * file, cocos2d::Camera* cam, cocos2d::Terrain* terrain);
65 virtual bool isDone() const;
66 virtual void update(float dt);
67
68 void turnLeft();
69 void turnRight();
70 void forward();
71 void backward();
72 void idle();
73 cocos2d::Vec3 _targetPos;
74 void updateState();
76 cocos2d::Vec3 _headingAxis;
77private:
78 cocos2d::Terrain* _terrain;
79 cocos2d::Camera* _cam;
81};
82
83
85{
86public:
89 virtual std::string title() const override;
90 virtual std::string subtitle() const override;
91 void onTouchesBegan(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event* event);
92 void onTouchesEnd(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event* event);
93protected:
94 cocos2d::Camera* _camera;
95 cocos2d::Terrain* _terrain;
97};
98
100{
101public:
104 virtual std::string title() const override;
105 virtual std::string subtitle() const override;
106 void onTouchesMoved(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event* event);
107
108protected:
109 cocos2d::Terrain* _terrain;
110 cocos2d::Camera* _camera;
111};
112
113#endif // !TERRAIN_TESH_H
DEFINE_TEST_SUITE(TerrainTests)
cocos2d::Terrain * _terrain
Definition: TerrainTest.h:78
cocos2d::Vec3 _targetPos
Definition: TerrainTest.h:73
static Player * create(const char *file, cocos2d::Camera *cam, cocos2d::Terrain *terrain)
void turnLeft()
virtual bool isDone() const
float _headingAngle
Definition: TerrainTest.h:75
void turnRight()
cocos2d::Vec3 _headingAxis
Definition: TerrainTest.h:76
void backward()
cocos2d::Camera * _cam
Definition: TerrainTest.h:79
void idle()
void updateState()
virtual void update(float dt)
void forward()
int _playerState
Definition: TerrainTest.h:80
virtual std::string title() const override
Definition: TerrainTest.cpp:70
void onTouchesMoved(const std::vector< cocos2d::Touch * > &touches, cocos2d::Event *event)
Definition: TerrainTest.cpp:80
cocos2d::Camera * _camera
Definition: TerrainTest.h:52
cocos2d::Terrain * _terrain
Definition: TerrainTest.h:50
CREATE_FUNC(TerrainSimple)
virtual std::string subtitle() const override
Definition: TerrainTest.cpp:75
std::string _title
Definition: TerrainTest.h:39
Player * _player
Definition: TerrainTest.h:96
CREATE_FUNC(TerrainWalkThru)
void onTouchesEnd(const std::vector< cocos2d::Touch * > &touches, cocos2d::Event *event)
cocos2d::Camera * _camera
Definition: TerrainTest.h:94
virtual std::string title() const override
cocos2d::Terrain * _terrain
Definition: TerrainTest.h:95
void onTouchesBegan(const std::vector< cocos2d::Touch * > &touches, cocos2d::Event *event)
virtual std::string subtitle() const override
cocos2d::Terrain * _terrain
Definition: TerrainTest.h:109
virtual std::string title() const override
virtual std::string subtitle() const override
cocos2d::Camera * _camera
Definition: TerrainTest.h:110
void onTouchesMoved(const std::vector< cocos2d::Touch * > &touches, cocos2d::Event *event)
CREATE_FUNC(TerrainWithLightMap)