Skip to content

Run SpriteTest successful #173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
5 commits merged into from
Mar 15, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion HelloWorld/HelloWorldScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ bool HelloWorld::init()
this->addChild(pLabel, 1);

// add "HelloWorld" splash screen"
CCSprite* pSprite = CCSprite::spriteWithFile("HelloWorld.jpg");
CCSprite* pSprite = CCSprite::spriteWithFile("HelloWorld.png");

// position the sprite on the center of the screen
pSprite->setPosition( ccp(size.width/2, size.height/2) );
Expand Down
Binary file removed HelloWorld/Resource/HelloWorld.jpg
Binary file not shown.
10 changes: 4 additions & 6 deletions cocos2dx/include/CCLabelTTF.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,8 @@ namespace cocos2d{
class CC_DLL CCLabelTTF : public CCSprite, public CCLabelProtocol
{
public:
CCLabelTTF()
:m_sFontName("")
{}
virtual ~CCLabelTTF(){ m_sFontName.clear(); }
CCLabelTTF() {}
virtual ~CCLabelTTF(){}
char * description();
/** creates a CCLabelTTF from a fontname, alignment, dimension and font size */
static CCLabelTTF * labelWithString(const char *label, CCSize dimensions, UITextAlignment alignment, const char *fontName, float fontSize);
Expand All @@ -61,9 +59,9 @@ namespace cocos2d{
protected:
CCSize m_tDimensions;
UITextAlignment m_eAlignment;
std::string m_sFontName;
ccxScopedPtr<std::string> m_pFontName;
float m_fFontSize;
std::string m_sString;
ccxScopedPtr<std::string> m_pString;
};

} //namespace cocos2d
Expand Down
14 changes: 7 additions & 7 deletions cocos2dx/label_nodes/CCLabelTTF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ namespace cocos2d{
{
m_tDimensions = CCSizeMake( dimensions.width * CC_CONTENT_SCALE_FACTOR(), dimensions.height * CC_CONTENT_SCALE_FACTOR() );
m_eAlignment = alignment;
m_sFontName = fontName;
m_pFontName.reset(new std::string(fontName));
m_fFontSize = fontSize * CC_CONTENT_SCALE_FACTOR();
this->setString(label);
return true;
Expand All @@ -70,7 +70,7 @@ namespace cocos2d{
if (CCSprite::init())
{
m_tDimensions = CCSizeZero;
m_sFontName = fontName;
m_pFontName.reset(new std::string(fontName));
m_fFontSize = fontSize * CC_CONTENT_SCALE_FACTOR();
this->setString(label);
return true;
Expand All @@ -79,18 +79,18 @@ namespace cocos2d{
}
void CCLabelTTF::setString(const char *label)
{
m_sString = string(label);
m_pString.reset(new std::string(label));

CCTexture2D *texture;
if( CCSize::CCSizeEqualToSize( m_tDimensions, CCSizeZero ) )
{
texture = new CCTexture2D();
texture->initWithString(label, m_sFontName.c_str(), m_fFontSize);
texture->initWithString(label, m_pFontName->c_str(), m_fFontSize);
}
else
{
texture = new CCTexture2D();
texture->initWithString(label, m_tDimensions, m_eAlignment, m_sFontName.c_str(), m_fFontSize);
texture->initWithString(label, m_tDimensions, m_eAlignment, m_pFontName->c_str(), m_fFontSize);
}
this->setTexture(texture);
texture->release();
Expand All @@ -102,13 +102,13 @@ namespace cocos2d{

const char* CCLabelTTF::getString(void)
{
return m_sString.c_str();
return m_pString->c_str();
}

char * CCLabelTTF::description()
{
char *ret = new char[100] ;
sprintf(ret, "<CCLabelTTF | FontName = %s, FontSize = %.1f>", m_sFontName.c_str(), m_fFontSize);
sprintf(ret, "<CCLabelTTF | FontName = %s, FontSize = %.1f>", m_pFontName->c_str(), m_fFontSize);
return ret;
}
}// namespace cocos2d
2 changes: 1 addition & 1 deletion cocos2dx/platform/CCCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct ccxNewArrayDeleter { template< class TPTR > void operator()(TPTR p) { d
@brief A simple scoped pointer.
*/
template < class T, class D = ccxNewDeleter >
class ccxScopedPtr // noncopyable
class CC_DLL ccxScopedPtr // noncopyable
: private D
{
public:
Expand Down
16 changes: 16 additions & 0 deletions cocos2dx/platform/wophone/CCAccelerometer_wophone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,22 @@ void CCAccelerometer::removeDelegate(CCAccelerometerDelegate* pDelegate)

void CCAccelerometer::addDelegate(CCAccelerometerDelegate* pDelegate)
{
CCAccelerometerHandler *pHandlerIter;
CCMutableArray<CCAccelerometerHandler*>::CCMutableArrayIterator iter;

if (pDelegate)
{
for (iter = m_pDelegates->begin(); iter != m_pDelegates->end(); ++iter)
{
pHandlerIter = *iter;
if (pHandlerIter && pHandlerIter->getDelegate() == pDelegate)
{
// this delegate have existed
return;
}
}
}

CCAccelerometerHandler* pHandler = CCAccelerometerHandler::handlerWithDelegate(pDelegate);

if (pHandler)
Expand Down
2 changes: 1 addition & 1 deletion cocos2dx/sprite_nodes/CCAnimationCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ namespace cocos2d
}

CCAnimationCache::CCAnimationCache()
: m_pAnimations(NULL)
{
assert(m_pAnimations == NULL);
}

CCAnimationCache::~CCAnimationCache()
Expand Down
7 changes: 3 additions & 4 deletions cocos2dx/sprite_nodes/CCSprite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -978,11 +978,10 @@ void CCSprite::setDisplayFrame(CCSpriteFrame *pNewFrame)

CCTexture2D *pNewTexture = pNewFrame->getTexture();
// update texture before updating texture rect
if (!m_pobTexture ||
pNewTexture->getName() != m_pobTexture->getName())
{
if (pNewTexture != m_pobTexture)
{
setTexture(pNewTexture);
}
}

// update rect
m_bRectRotated = pNewFrame->isRotated();
Expand Down
7 changes: 6 additions & 1 deletion cocos2dx/sprite_nodes/CCSpriteFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ bool CCSpriteFrame::initWithTexture(CCTexture2D* pobTexture, CCRect rect)
bool CCSpriteFrame::initWithTexture(CCTexture2D* pobTexture, CCRect rect, bool rotated, CCPoint offset, CCSize originalSize)
{
m_pobTexture = pobTexture;
pobTexture->retain();

if (pobTexture)
{
pobTexture->retain();
}

m_obRectInPixels = rect;
m_obRect = CC_RECT_PIXELS_TO_POINTS(rect);
m_bRotated = rotated;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<!-- Page 2 Controls -->
<SYMBOL NAME='CC_USE_BOX2D' TYPE="checkbox" VALUE="true"></SYMBOL>
<SYMBOL NAME='CC_USE_CHIPMUNK' TYPE="checkbox" VALUE="false"></SYMBOL>
<SYMBOL NAME='CC_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE' TYPE="checkbox" VALUE="false"></SYMBOL>
<SYMBOL NAME='CC_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE' TYPE="checkbox" VALUE="true"></SYMBOL>
<SYMBOL NAME='CC_HAS_MAIN_FORM' TYPE="checkbox" VALUE="true"></SYMBOL>

<SYMBOL NAME='CC_USE_TCOM_SUPPORT' TYPE="checkbox" VALUE="false"></SYMBOL>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function CreateCustomProject(strProjectName, strProjectPath) {
if(WizardVersion >= 10.0)
strUserValue = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n <PropertyGroup>\r\n <ShowAllFiles>true</ShowAllFiles>\r\n </PropertyGroup>\r\n</Project>";
else
strUserValue = "<?xml version=\"1.0\" encoding=\"utf-8\"?><VisualStudioUserFile ProjectType=\"Visual C++\" Version=\"9.00\" ShowAllFiles=\"true\"></VisualStudioUserFile>";
strUserValue = "<?xml version=\"1.0\" encoding=\"utf-8\"?><VisualStudioUserFile ProjectType=\"Visual C++\" Version=\"9.00\" ShowAllFiles=\"true\"><Configurations><Configuration Name=\"Debug|Win32\"><DebugSettings Command=\"TG3_RunDLL.exe\" CommandArguments=\"$(TargetPath)\"/></Configuration></VisualStudioUserFile>";
file.WriteLine(strUserValue);
file.Close();

Expand Down Expand Up @@ -173,7 +173,7 @@ function AddConfigurations(proj, strProjectName) {
// header files and libraries directories
var strOutputDir = '../../PRJ_TG3/LIB/Win32Lib';
var strCurIncludeDir = '..\\..\\PRJ_TG3\\Include;..\\..\\PRJ_TG3\\Include\\MTAPI;..\\..\\PRJ_TG3\\Include\\ThirdParty;..\\..\\PRJ_TG3\\Include\\TCOM;..\\..\\PRJ_TG3\\Include\\OpenGL';
strCurIncludeDir += ';.;.\\Classes;.\\wophone;.\\wophone\\Res;..\\cocos2dx;..\\cocos2dx\\include';
strCurIncludeDir += ';.;.\\Classes;.\\wophone;.\\wophone\\Res;..\\cocos2dx;..\\cocos2dx\\include;..\\cocos2dx\\platform';

var strDefinitions = 'WIN32;_CONSOLE;_TRANZDA_VM_;SS_MAKEDLL';
var strDependLibs = 'WS2_32.Lib EosConfig.lib SoftSupport.lib TG3_DLL.lib libcocos2d.lib';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ bool AppDelegate::initInstance()
// Use GetScreenWidth() and GetScreenHeight() get screen width and height.
CCEGLView * pMainWnd = new CCEGLView(this);
CC_BREAK_IF(! pMainWnd
|| ! pMainWnd->Create(&TRectangle(0, 0, 320, 480)));
|| ! pMainWnd->Create(320, 480));

#if !defined(_TRANZDA_VM_)
// set the resource zip file
// on wophone emulator, we copy resources files to Work7/TG3/APP/ folder instead of zip file
CCFileUtils::setResource("[!output PROJECT_NAME].zip");
#endif

bRet = true;
} while (0);
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ Classes/HelloWorldScene.cpp

Resource/CloseNormal.png
Resource/CloseSelected.png
Resource/HelloWorld.png
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ INCLUDE_TMK3=$(TO_PROJECT_ROOT)/MakeInclude/TG3_APP_Arm.TMK3 ;TOPS标准应
;PRE_DEFINE=USE_MTAPI=1 ;使用 MTAPI 库,此时生成的 Makefile 会自动连接有关的LIB

;C、C++预定义宏,可以使用多个DEFINES串,也可以使用DEFINES1、DEFINES2等方式,MakeFile中依据出现顺序(不是数字大小)排列
DEFINES=-DCC_UNDER_UPHONE ;这里填入应用的自定义宏。注意:ITOPS自己的所需定义会自动包含,故此这里仅仅包含应用自己特有的定义即可
DEFINES=-DCC_UNDER_WOPHONE ;这里填入应用的自定义宏。注意:ITOPS自己的所需定义会自动包含,故此这里仅仅包含应用自己特有的定义即可
;DEFINES=-D__TG3_PURE_DLL__ ;生成的是纯动态库(意思是:不是TOPS应用,但可以是TCOM组件)
[!if CC_USE_TCOM_SUPPORT]
DEFINES=-D__TCOM_SUPPORT__ ;生成的是TCOM组件(注意:TOPS应用也可以同时是TCOM组件)
Expand All @@ -37,7 +37,7 @@ DEFINES=-D__TCOM_SUPPORT__ ;生成的是TCOM组件(注意:TOPS应用也
[!endif]

;包含路径,可以使用多个INCLUDE_PATH串,也可以使用INCLUDE_PATH1、INCLUDE_PATH2等方式,MakeFile中依据出现顺序(不是数字大小)排列
INCLUDE_PATH=-I ../../PRJ_TG3/Include/OpenGL -I../cocos2dx -I../cocos2dx/include
INCLUDE_PATH=-I ../../PRJ_TG3/Include/OpenGL -I../cocos2dx -I../cocos2dx/include -I../cocos2dx/platform
INCLUDE_PATH=-I. -I./Classes -I./wophone -I./wophone/Res ;默认本项目的路径
[! if CC_USE_BOX2D]
INCLUDE_PATH=-I../ -I../Box2D
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ Int32 TG3AppMain(const TUChar * pAppID, UInt32 nCmd, void * pCmdParam)
{
AppDelegate app;

cocos2d::CCApplication::sharedApplication().run();
cocos2d::CCApplication::sharedApplication().Run();
return 1;
}
2 changes: 1 addition & 1 deletion tests/Res/TileMaps/iso-test-bug787.tmx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!DOCTYPE map SYSTEM "http://mapeditor.org/dtd/1.0/map.dtd">
<map version="1.0" orientation="isometric" width="64" height="64" tilewidth="64" tileheight="32">
<tileset firstgid="1" name="Untitled" tilewidth="64" tileheight="115" spacing="2" margin="2">
<image source="../TileMaps/iso-test.png"/>
<image source="iso-test.png"/>
</tileset>
<layer name="Layer 0" width="64" height="64">
<data encoding="base64" compression="gzip">
Expand Down
9 changes: 7 additions & 2 deletions tests/tests/SpriteTest/SpriteTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ CCLayer* createSpriteTestLayer(int nIndex)
case 0: return new Sprite1();
case 1: return new SpriteBatchNode1();
case 2: return new SpriteFrameTest();
/*
@todo should add this case after issue #391 is resolved
case 3: return new SpriteFrameAliasNameTest();
*/

case 3: return new AnimationCache();////----
case 4: return new SpriteAnchorPoint();
case 5: return new SpriteBatchNodeAnchorPoint();
case 6: return new SpriteOffsetAnchorRotation();
Expand Down Expand Up @@ -80,7 +85,6 @@ CCLayer* createSpriteTestLayer(int nIndex)
case 38: return new SpriteBatchNodeChildrenChildren();
case 39: return new SpriteNilTexture();
case 40: return new SpriteSubclass();
case 41: return new AnimationCache();
}

return NULL;
Expand Down Expand Up @@ -1729,8 +1733,9 @@ void SpriteFrameTest::flipSprites(ccTime dt)
// SpriteFrameAliasNameTest
//
//------------------------------------------------------------------
SpriteFrameAliasNameTest::SpriteFrameAliasNameTest()
void SpriteFrameAliasNameTest::onEnter()
{
SpriteTestDemo::onEnter();
CCSize s = CCDirector::sharedDirector()->getWinSize();

// IMPORTANT:
Expand Down
2 changes: 1 addition & 1 deletion tests/tests/SpriteTest/SpriteTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ class SpriteFrameTest: public SpriteTestDemo
class SpriteFrameAliasNameTest : public SpriteTestDemo
{
public:
SpriteFrameAliasNameTest();
virtual void onEnter();
~SpriteFrameAliasNameTest();
virtual std::string title();
virtual std::string subtitle();
Expand Down