Skip to content

Commit f2df035

Browse files
author
natural-law
committed
fixed cocos2d#162
Add HiResTest code
1 parent 1f8f8e7 commit f2df035

File tree

9 files changed

+262
-3
lines changed

9 files changed

+262
-3
lines changed

Box2D/Box2D.vcproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
/>
7878
<Tool
7979
Name="VCPostBuildEventTool"
80-
CommandLine="mkdir D:\Work7\PRJ_TG3\Include\Box2D&#x0D;&#x0A;mkdir D:\Work7\PRJ_TG3\Include\Box2D\Collision&#x0D;&#x0A;mkdir D:\Work7\PRJ_TG3\Include\Box2D\Collision\Shapes&#x0D;&#x0A;mkdir D:\Work7\PRJ_TG3\Include\Box2D\Common&#x0D;&#x0A;mkdir D:\Work7\PRJ_TG3\Include\Box2D\Dynamics&#x0D;&#x0A;mkdir D:\Work7\PRJ_TG3\Include\Box2D\Dynamics\Contacts&#x0D;&#x0A;mkdir D:\Work7\PRJ_TG3\Include\Box2D\Dynamics\Joints&#x0D;&#x0A;copy .\*.h D:\Work7\PRJ_TG3\Include\Box2D&#x0D;&#x0A;copy .\Collision\*.h D:\Work7\PRJ_TG3\Include\Box2D\Collision&#x0D;&#x0A;copy .\Collision\Shapes\*.h D:\Work7\PRJ_TG3\Include\Box2D\Collision\Shapes&#x0D;&#x0A;copy .\Common\*.h D:\Work7\PRJ_TG3\Include\Box2D\Common&#x0D;&#x0A;copy .\Dynamics\*.h D:\Work7\PRJ_TG3\Include\Box2D\Dynamics&#x0D;&#x0A;copy .\Dynamics\Contacts\*.h D:\Work7\PRJ_TG3\Include\Box2D\Dynamics\Contacts&#x0D;&#x0A;copy .\Dynamics\Joints\*.h D:\Work7\PRJ_TG3\Include\Box2D\Dynamics\Joints"
80+
CommandLine=""
8181
/>
8282
</Configuration>
8383
<Configuration
3.52 KB
Loading

test_uphone/test_uphone.vcproj

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
<Tool
4242
Name="VCCLCompilerTool"
4343
Optimization="0"
44-
AdditionalIncludeDirectories=".\Res;..\..\PRJ_TG3\Include;..\..\PRJ_TG3\Include\MTAPI;..\..\PRJ_TG3\Include\OpenGL;..\..\PRJ_TG3\Include\TCOM;..\..\PRJ_TG3\TG3\Include;..\..\PRJ_TG3\TG3\TG3_Implement;..\..\PRJ_TG3\EOS_SYS;..\..\PRJ_TG3\Common\SoftSupport;..\..\PRJ_TG3\Common\ICU\Include;..\cocos2dx\include;..\cocos2dx;..\chipmunk\include\chipmunk;..\chipmunk\Demo;.\tests"
44+
AdditionalIncludeDirectories=".\Res;..\..\PRJ_TG3\Include;..\..\PRJ_TG3\Include\MTAPI;..\..\PRJ_TG3\Include\OpenGL;..\..\PRJ_TG3\Include\TCOM;..\..\PRJ_TG3\TG3\Include;..\..\PRJ_TG3\TG3\TG3_Implement;..\..\PRJ_TG3\EOS_SYS;..\..\PRJ_TG3\Common\SoftSupport;..\..\PRJ_TG3\Common\ICU\Include;..\cocos2dx\include;..\cocos2dx;..\chipmunk\include\chipmunk;..\;..\chipmunk\Demo;.\tests"
4545
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_TRANZDA_VM_;SS_MAKEDLL;_USE_MATH_DEFINES"
4646
MinimalRebuild="true"
4747
BasicRuntimeChecks="3"
@@ -867,6 +867,18 @@
867867
>
868868
</File>
869869
</Filter>
870+
<Filter
871+
Name="HiResTest"
872+
>
873+
<File
874+
RelativePath=".\tests\HiResTest\HiResTest.cpp"
875+
>
876+
</File>
877+
<File
878+
RelativePath=".\tests\HiResTest\HiResTest.h"
879+
>
880+
</File>
881+
</Filter>
870882
</Filter>
871883
</Files>
872884
<Globals>

test_uphone/tests/Box2DTest/Box2dTest.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define _BOX2D_TEST_H_
33

44
#include "cocos2d.h"
5-
#include "Box2D/Box2d.h"
5+
#include "Box2d/Box2d.h"
66
#include "../testBasic.h"
77

88
class Box2DTestLayer : public CCLayer
Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
#include "HiResTest.h"
2+
#include "../testResource.h"
3+
4+
#define MAX_LAYERS 2;
5+
static int sceneIdx = -1;
6+
7+
CCLayer* createHiResLayer(int idx)
8+
{
9+
CCLayer* pLayer = NULL;
10+
11+
switch (idx)
12+
{
13+
case 0:
14+
pLayer = new HiResTest1(); break;
15+
case 1:
16+
pLayer = new HiResTest2(); break;
17+
}
18+
19+
return pLayer;
20+
}
21+
22+
CCLayer* nextHiResAction()
23+
{
24+
sceneIdx++;
25+
sceneIdx = sceneIdx % MAX_LAYERS;
26+
27+
CCLayer* pLayer = createHiResLayer(sceneIdx);
28+
return pLayer;
29+
}
30+
31+
CCLayer* restartHiResAction()
32+
{
33+
CCLayer* pLayer = createHiResLayer(sceneIdx);
34+
return pLayer;
35+
}
36+
37+
CCLayer* backHiResAction()
38+
{
39+
sceneIdx--;
40+
if( sceneIdx < 0 )
41+
sceneIdx += MAX_LAYERS;
42+
43+
CCLayer* pLayer = createHiResLayer(sceneIdx);
44+
return pLayer;
45+
}
46+
47+
////////////////////////////////////
48+
//
49+
// HiResDemo
50+
//
51+
///////////////////////////////////
52+
void HiResDemo::onEnter()
53+
{
54+
CCLayer::onEnter();
55+
56+
CGSize s = CCDirector::getSharedDirector()->getWinSize();
57+
58+
/**
59+
@todo CCLabelTTF
60+
*/
61+
// CCLabelTTF *label = [CCLabelTTF labelWithString:[self title] fontName:@"Arial" fontSize:32];
62+
// [self addChild: label z:1];
63+
// [label setPosition: ccp(s.width/2, s.height-50)];
64+
// NSString *subtitle = [self subtitle];
65+
// if( subtitle ) {
66+
// CCLabelTTF *l = [CCLabelTTF labelWithString:subtitle fontName:@"Thonburi" fontSize:16];
67+
// [self addChild:l z:1];
68+
// [l setPosition:ccp(s.width/2, s.height-80)];
69+
// }
70+
71+
CCMenuItemImage *item1 = CCMenuItemImage::itemFromNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(HiResDemo::backCallback) );
72+
CCMenuItemImage *item2 = CCMenuItemImage::itemFromNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(HiResDemo::restartCallback) );
73+
CCMenuItemImage *item3 = CCMenuItemImage::itemFromNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(HiResDemo::nextCallback) );
74+
75+
CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL);
76+
77+
menu->setPosition( CGPointZero );
78+
item1->setPosition( CGPointMake( s.width/2 - 100,30) );
79+
item2->setPosition( CGPointMake( s.width/2, 30) );
80+
item3->setPosition( CGPointMake( s.width/2 + 100,30) );
81+
82+
addChild(menu, 1);
83+
}
84+
85+
std::string HiResDemo::title()
86+
{
87+
return "No title";
88+
}
89+
90+
std::string HiResDemo::subtitle()
91+
{
92+
return "";
93+
}
94+
95+
void HiResDemo::restartCallback(NSObject* pSender)
96+
{
97+
CCLayer* pLayer = restartHiResAction();
98+
99+
if (pLayer)
100+
{
101+
pLayer->autorelease();
102+
CCScene* pScene = new HiResTestScene();
103+
pScene->addChild(pLayer);
104+
105+
CCDirector::getSharedDirector()->replaceScene(pScene);
106+
pScene->release();
107+
}
108+
}
109+
110+
void HiResDemo::nextCallback(NSObject* pSender)
111+
{
112+
CCLayer* pLayer = nextHiResAction();
113+
114+
if (pLayer)
115+
{
116+
pLayer->autorelease();
117+
CCScene* pScene = new HiResTestScene();
118+
pScene->addChild(pLayer);
119+
120+
CCDirector::getSharedDirector()->replaceScene(pScene);
121+
pScene->release();
122+
}
123+
}
124+
125+
void HiResDemo::backCallback(NSObject* pSender)
126+
{
127+
CCLayer* pLayer = backHiResAction();
128+
129+
if (pLayer)
130+
{
131+
pLayer->autorelease();
132+
CCScene* pScene = new HiResTestScene();
133+
pScene->addChild(pLayer);
134+
135+
CCDirector::getSharedDirector()->replaceScene(pScene);
136+
pScene->release();
137+
}
138+
}
139+
140+
////////////////////////////////////
141+
//
142+
// HiResTest1
143+
//
144+
///////////////////////////////////
145+
void HiResTest1::onEnter()
146+
{
147+
HiResDemo::onEnter();
148+
149+
CGSize size = CCDirector::getSharedDirector()->getWinSize();
150+
151+
CCSprite *sprite = CCSprite::spriteWithFile("Images/grossini.png");
152+
addChild(sprite);
153+
sprite->setPosition(ccp(size.width/2, size.height/2));
154+
}
155+
156+
std::string HiResTest1::title()
157+
{
158+
return "Standard image";
159+
}
160+
161+
////////////////////////////////////
162+
//
163+
// HiResTest2
164+
//
165+
///////////////////////////////////
166+
void HiResTest2::onEnter()
167+
{
168+
HiResDemo::onEnter();
169+
170+
CGSize size = CCDirector::getSharedDirector()->getWinSize();
171+
172+
CCSprite *sprite = CCSprite::spriteWithFile("Images/bugs/picture.png");
173+
addChild(sprite);
174+
sprite->setPosition(ccp(size.width/2, size.height/2));
175+
}
176+
177+
std::string HiResTest2::title()
178+
{
179+
return "@2x images";
180+
}
181+
182+
std::string HiResTest2::subtitle()
183+
{
184+
return "Issue #910";
185+
}
186+
187+
////////////////////////////////////
188+
//
189+
// HiResTestScene
190+
//
191+
///////////////////////////////////
192+
void HiResTestScene::runThisTest()
193+
{
194+
CCLayer* pLayer = nextHiResAction();
195+
addChild(pLayer);
196+
197+
pLayer->release();
198+
CCDirector::getSharedDirector()->replaceScene(this);
199+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#ifndef _HIRES_TEST_H_
2+
#define _HIRES_TEST_H_
3+
4+
#include "../testBasic.h"
5+
6+
class HiResDemo : public CCLayer
7+
{
8+
public:
9+
virtual std::string title();
10+
virtual std::string subtitle();
11+
virtual void onEnter();
12+
13+
void restartCallback(NSObject* pSender);
14+
void nextCallback(NSObject* pSender);
15+
void backCallback(NSObject* pSender);
16+
};
17+
18+
class HiResTest1 : public HiResDemo
19+
{
20+
public:
21+
virtual void onEnter();
22+
23+
virtual std::string title();
24+
};
25+
26+
class HiResTest2 : public HiResDemo
27+
{
28+
public:
29+
virtual void onEnter();
30+
31+
virtual std::string title();
32+
virtual std::string subtitle();
33+
};
34+
35+
class HiResTestScene : public TestScene
36+
{
37+
public:
38+
virtual void runThisTest();
39+
};
40+
41+
#endif

test_uphone/tests/controller.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ static TestScene* CreateTestScene(int nIdx)
6868
pScene = new Box2dTestBedScene(); break;
6969
case TEST_EFFECT_ADVANCE:
7070
pScene = new EffectAdvanceScene(); break;
71+
case TEST_HIRES:
72+
pScene = new HiResTestScene(); break;
7173
default:
7274
break;
7375
}

test_uphone/tests/tests.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "Box2DTest/Box2dTest.h"
2929
#include "Box2DTestBed/Box2dView.h"
3030
#include "EffectsAdvancedTest/EffectsAdvancedTest.h"
31+
#include "HiResTest/HiResTest.h"
3132

3233
enum
3334
{
@@ -58,6 +59,7 @@ enum
5859
TEST_BOX2D,
5960
TEST_BOX2DBED,
6061
TEST_EFFECT_ADVANCE,
62+
TEST_HIRES,
6163

6264
TESTS_COUNT,
6365
};
@@ -90,6 +92,7 @@ const std::string g_aTestNames[TESTS_COUNT] = {
9092
"Box2dTest",
9193
"Box2dTestBed",
9294
"EffectAdvancedTest",
95+
"HiResTest",
9396
};
9497

9598
#endif

test_uphone/tests/tests_post_commond.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ mkdir D:\Work7\NEWPLUS\TDA_DATA\Data\cocos2d_tests\Images
22
mkdir D:\Work7\NEWPLUS\TDA_DATA\Data\cocos2d_tests\TileMaps
33
mkdir D:\Work7\NEWPLUS\TDA_DATA\Data\cocos2d_tests\fonts
44
mkdir D:\Work7\NEWPLUS\TDA_DATA\Data\cocos2d_tests\animations
5+
mkdir D:\Work7\NEWPLUS\TDA_DATA\Data\cocos2d_tests\Images\bugs
56
copy .\Res\Images\*.* D:\Work7\NEWPLUS\TDA_DATA\Data\cocos2d_tests\Images
7+
copy .\Res\Images\bugs\*.* D:\Work7\NEWPLUS\TDA_DATA\Data\cocos2d_tests\Images\bugs
68
copy .\Res\TileMaps\*.* D:\Work7\NEWPLUS\TDA_DATA\Data\cocos2d_tests\TileMaps
79
copy .\Res\fonts\*.* D:\Work7\NEWPLUS\TDA_DATA\Data\cocos2d_tests\fonts
810
copy .\Res\animations\*.* D:\Work7\NEWPLUS\TDA_DATA\Data\cocos2d_tests\animations

0 commit comments

Comments
 (0)