Skip to content

Commit

Permalink
fixed cocos2d#162
Browse files Browse the repository at this point in the history
Add HiResTest code
  • Loading branch information
natural-law committed Sep 24, 2010
1 parent 1f8f8e7 commit f2df035
Show file tree
Hide file tree
Showing 9 changed files with 262 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Box2D/Box2D.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
/>
<Tool
Name="VCPostBuildEventTool"
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"
CommandLine=""
/>
</Configuration>
<Configuration
Expand Down
Binary file added test_uphone/Res/Images/bugs/picture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 13 additions & 1 deletion test_uphone/test_uphone.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
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"
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"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_TRANZDA_VM_;SS_MAKEDLL;_USE_MATH_DEFINES"
MinimalRebuild="true"
BasicRuntimeChecks="3"
Expand Down Expand Up @@ -867,6 +867,18 @@
>
</File>
</Filter>
<Filter
Name="HiResTest"
>
<File
RelativePath=".\tests\HiResTest\HiResTest.cpp"
>
</File>
<File
RelativePath=".\tests\HiResTest\HiResTest.h"
>
</File>
</Filter>
</Filter>
</Files>
<Globals>
Expand Down
2 changes: 1 addition & 1 deletion test_uphone/tests/Box2DTest/Box2dTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define _BOX2D_TEST_H_

#include "cocos2d.h"
#include "Box2D/Box2d.h"
#include "Box2d/Box2d.h"
#include "../testBasic.h"

class Box2DTestLayer : public CCLayer
Expand Down
199 changes: 199 additions & 0 deletions test_uphone/tests/HiResTest/HiResTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
#include "HiResTest.h"
#include "../testResource.h"

#define MAX_LAYERS 2;
static int sceneIdx = -1;

CCLayer* createHiResLayer(int idx)
{
CCLayer* pLayer = NULL;

switch (idx)
{
case 0:
pLayer = new HiResTest1(); break;
case 1:
pLayer = new HiResTest2(); break;
}

return pLayer;
}

CCLayer* nextHiResAction()
{
sceneIdx++;
sceneIdx = sceneIdx % MAX_LAYERS;

CCLayer* pLayer = createHiResLayer(sceneIdx);
return pLayer;
}

CCLayer* restartHiResAction()
{
CCLayer* pLayer = createHiResLayer(sceneIdx);
return pLayer;
}

CCLayer* backHiResAction()
{
sceneIdx--;
if( sceneIdx < 0 )
sceneIdx += MAX_LAYERS;

CCLayer* pLayer = createHiResLayer(sceneIdx);
return pLayer;
}

////////////////////////////////////
//
// HiResDemo
//
///////////////////////////////////
void HiResDemo::onEnter()
{
CCLayer::onEnter();

CGSize s = CCDirector::getSharedDirector()->getWinSize();

/**
@todo CCLabelTTF
*/
// CCLabelTTF *label = [CCLabelTTF labelWithString:[self title] fontName:@"Arial" fontSize:32];
// [self addChild: label z:1];
// [label setPosition: ccp(s.width/2, s.height-50)];
// NSString *subtitle = [self subtitle];
// if( subtitle ) {
// CCLabelTTF *l = [CCLabelTTF labelWithString:subtitle fontName:@"Thonburi" fontSize:16];
// [self addChild:l z:1];
// [l setPosition:ccp(s.width/2, s.height-80)];
// }

CCMenuItemImage *item1 = CCMenuItemImage::itemFromNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(HiResDemo::backCallback) );
CCMenuItemImage *item2 = CCMenuItemImage::itemFromNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(HiResDemo::restartCallback) );
CCMenuItemImage *item3 = CCMenuItemImage::itemFromNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(HiResDemo::nextCallback) );

CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL);

menu->setPosition( CGPointZero );
item1->setPosition( CGPointMake( s.width/2 - 100,30) );
item2->setPosition( CGPointMake( s.width/2, 30) );
item3->setPosition( CGPointMake( s.width/2 + 100,30) );

addChild(menu, 1);
}

std::string HiResDemo::title()
{
return "No title";
}

std::string HiResDemo::subtitle()
{
return "";
}

void HiResDemo::restartCallback(NSObject* pSender)
{
CCLayer* pLayer = restartHiResAction();

if (pLayer)
{
pLayer->autorelease();
CCScene* pScene = new HiResTestScene();
pScene->addChild(pLayer);

CCDirector::getSharedDirector()->replaceScene(pScene);
pScene->release();
}
}

void HiResDemo::nextCallback(NSObject* pSender)
{
CCLayer* pLayer = nextHiResAction();

if (pLayer)
{
pLayer->autorelease();
CCScene* pScene = new HiResTestScene();
pScene->addChild(pLayer);

CCDirector::getSharedDirector()->replaceScene(pScene);
pScene->release();
}
}

void HiResDemo::backCallback(NSObject* pSender)
{
CCLayer* pLayer = backHiResAction();

if (pLayer)
{
pLayer->autorelease();
CCScene* pScene = new HiResTestScene();
pScene->addChild(pLayer);

CCDirector::getSharedDirector()->replaceScene(pScene);
pScene->release();
}
}

////////////////////////////////////
//
// HiResTest1
//
///////////////////////////////////
void HiResTest1::onEnter()
{
HiResDemo::onEnter();

CGSize size = CCDirector::getSharedDirector()->getWinSize();

CCSprite *sprite = CCSprite::spriteWithFile("Images/grossini.png");
addChild(sprite);
sprite->setPosition(ccp(size.width/2, size.height/2));
}

std::string HiResTest1::title()
{
return "Standard image";
}

////////////////////////////////////
//
// HiResTest2
//
///////////////////////////////////
void HiResTest2::onEnter()
{
HiResDemo::onEnter();

CGSize size = CCDirector::getSharedDirector()->getWinSize();

CCSprite *sprite = CCSprite::spriteWithFile("Images/bugs/picture.png");
addChild(sprite);
sprite->setPosition(ccp(size.width/2, size.height/2));
}

std::string HiResTest2::title()
{
return "@2x images";
}

std::string HiResTest2::subtitle()
{
return "Issue #910";
}

////////////////////////////////////
//
// HiResTestScene
//
///////////////////////////////////
void HiResTestScene::runThisTest()
{
CCLayer* pLayer = nextHiResAction();
addChild(pLayer);

pLayer->release();
CCDirector::getSharedDirector()->replaceScene(this);
}
41 changes: 41 additions & 0 deletions test_uphone/tests/HiResTest/HiResTest.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#ifndef _HIRES_TEST_H_
#define _HIRES_TEST_H_

#include "../testBasic.h"

class HiResDemo : public CCLayer
{
public:
virtual std::string title();
virtual std::string subtitle();
virtual void onEnter();

void restartCallback(NSObject* pSender);
void nextCallback(NSObject* pSender);
void backCallback(NSObject* pSender);
};

class HiResTest1 : public HiResDemo
{
public:
virtual void onEnter();

virtual std::string title();
};

class HiResTest2 : public HiResDemo
{
public:
virtual void onEnter();

virtual std::string title();
virtual std::string subtitle();
};

class HiResTestScene : public TestScene
{
public:
virtual void runThisTest();
};

#endif
2 changes: 2 additions & 0 deletions test_uphone/tests/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ static TestScene* CreateTestScene(int nIdx)
pScene = new Box2dTestBedScene(); break;
case TEST_EFFECT_ADVANCE:
pScene = new EffectAdvanceScene(); break;
case TEST_HIRES:
pScene = new HiResTestScene(); break;
default:
break;
}
Expand Down
3 changes: 3 additions & 0 deletions test_uphone/tests/tests.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "Box2DTest/Box2dTest.h"
#include "Box2DTestBed/Box2dView.h"
#include "EffectsAdvancedTest/EffectsAdvancedTest.h"
#include "HiResTest/HiResTest.h"

enum
{
Expand Down Expand Up @@ -58,6 +59,7 @@ enum
TEST_BOX2D,
TEST_BOX2DBED,
TEST_EFFECT_ADVANCE,
TEST_HIRES,

TESTS_COUNT,
};
Expand Down Expand Up @@ -90,6 +92,7 @@ const std::string g_aTestNames[TESTS_COUNT] = {
"Box2dTest",
"Box2dTestBed",
"EffectAdvancedTest",
"HiResTest",
};

#endif
2 changes: 2 additions & 0 deletions test_uphone/tests/tests_post_commond.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ mkdir D:\Work7\NEWPLUS\TDA_DATA\Data\cocos2d_tests\Images
mkdir D:\Work7\NEWPLUS\TDA_DATA\Data\cocos2d_tests\TileMaps
mkdir D:\Work7\NEWPLUS\TDA_DATA\Data\cocos2d_tests\fonts
mkdir D:\Work7\NEWPLUS\TDA_DATA\Data\cocos2d_tests\animations
mkdir D:\Work7\NEWPLUS\TDA_DATA\Data\cocos2d_tests\Images\bugs
copy .\Res\Images\*.* D:\Work7\NEWPLUS\TDA_DATA\Data\cocos2d_tests\Images
copy .\Res\Images\bugs\*.* D:\Work7\NEWPLUS\TDA_DATA\Data\cocos2d_tests\Images\bugs
copy .\Res\TileMaps\*.* D:\Work7\NEWPLUS\TDA_DATA\Data\cocos2d_tests\TileMaps
copy .\Res\fonts\*.* D:\Work7\NEWPLUS\TDA_DATA\Data\cocos2d_tests\fonts
copy .\Res\animations\*.* D:\Work7\NEWPLUS\TDA_DATA\Data\cocos2d_tests\animations

0 comments on commit f2df035

Please sign in to comment.