mirror of https://github.com/axmolengine/axmol.git
parent
1ce2c6dad8
commit
0dbda6c32d
|
@ -223,14 +223,6 @@
|
|||
RelativePath=".\Res\background-music-aac.mp3"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Res\CloseNormal.png"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Res\CloseSelected.png"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Res\Cocos2dSimpleGame_Res.ENU.tr3"
|
||||
>
|
||||
|
@ -267,18 +259,54 @@
|
|||
RelativePath=".\Res\pew-pew-lei.wav"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Res\Player.png"
|
||||
<Filter
|
||||
Name="HVGARes"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Res\Projectile.png"
|
||||
<File
|
||||
RelativePath=".\Res\HVGARes\CloseNormal.png"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Res\HVGARes\CloseSelected.png"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Res\HVGARes\Player.png"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Res\HVGARes\Projectile.png"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Res\HVGARes\Target.png"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="WVGARes"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Res\Target.png"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Res\WVGARes\CloseNormal@WVGA.png"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Res\WVGARes\CloseSelected@WVGA.png"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Res\WVGARes\Player@WVGA.png"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Res\WVGARes\Projectile@WVGA.png"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Res\WVGARes\Target@WVGA.png"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Makefiles"
|
||||
|
|
|
@ -24,8 +24,8 @@ bool AppDelegate::initCocos2d()
|
|||
pDirector->setDisplayFPS(true);
|
||||
|
||||
// set the ResourceEntry and Images ResInfo (name and ResID)
|
||||
UIImage::setResourceEntry(&Cocos2dSimpleGameResourceEntry);
|
||||
UIImage::setImageResInfo(ResInfo, sizeof(ResInfo) / sizeof(T_ImageResInfo));
|
||||
CCFileUtils::setResourceEntry(&Cocos2dSimpleGameResourceEntry);
|
||||
CCFileUtils::setResourceInfo(ResInfo, sizeof(ResInfo) / sizeof(T_ResourceInfo));
|
||||
|
||||
// set the ResourceEntry and sound ResInfo (filename and ResID)
|
||||
SimpleAudioEngine::getSharedEngine()->setResourceEntry(&Cocos2dSimpleGameResourceEntry);
|
||||
|
|
|
@ -44,7 +44,7 @@ void HelloWorld::spriteMoveFinished(CCNode* sender)
|
|||
void HelloWorld::addTarget()
|
||||
{
|
||||
|
||||
CCSprite *target = CCSprite::spriteWithFile(ResInfo[4].ImgName.c_str(), CGRectMake(0,0,27,40));
|
||||
CCSprite *target = CCSprite::spriteWithFile(ResInfo[4].ResName.c_str());
|
||||
|
||||
// Determine where to spawn the target along the Y axis
|
||||
CGSize winSize = CCDirector::getSharedDirector()->getWinSize();
|
||||
|
@ -94,11 +94,11 @@ bool HelloWorld::init()
|
|||
// cocos2d-uphone: add a menu item with "X" image, which is clicked to quit the program
|
||||
// add a "close" icon, it's an autorelease object
|
||||
CCMenuItemImage *pCloseItem = CCMenuItemImage::itemFromNormalImage(
|
||||
ResInfo[0].ImgName.c_str(),
|
||||
ResInfo[1].ImgName.c_str(),
|
||||
ResInfo[0].ResName.c_str(),
|
||||
ResInfo[1].ResName.c_str(),
|
||||
this,
|
||||
menu_selector(HelloWorld::menuCloseCallback) );
|
||||
pCloseItem->setPosition( ccp( CCDirector::getSharedDirector()->getWinSize().width - 20, 20) );
|
||||
pCloseItem->setPosition( ccp( CCDirector::getSharedDirector()->getWinSize().width - 30, 30) );
|
||||
CCMenu* pMenu = CCMenu::menuWithItems(pCloseItem, NULL); // create menu, it's an autorelease object
|
||||
pMenu->setPosition( CGPointZero );
|
||||
this->addChild(pMenu);
|
||||
|
@ -121,7 +121,7 @@ bool HelloWorld::init()
|
|||
// and as close to the left side edge as we can get
|
||||
// Remember that position is based on the anchor point, and by default the anchor
|
||||
// point is the middle of the object.
|
||||
CCSprite *player = CCSprite::spriteWithFile(ResInfo[2].ImgName.c_str(), CGRectMake(0, 0, 27, 40) );
|
||||
CCSprite *player = CCSprite::spriteWithFile(ResInfo[2].ResName.c_str());
|
||||
player->setPosition( ccp(player->getContentSize().width / 2, winSize.height/2) );
|
||||
this->addChild(player);
|
||||
|
||||
|
@ -211,7 +211,7 @@ void HelloWorld::ccTouchesEnded(NSSet* touches, UIEvent* event)
|
|||
|
||||
// Set up initial location of projectile
|
||||
CGSize winSize = CCDirector::getSharedDirector()->getWinSize();
|
||||
CCSprite *projectile = CCSprite::spriteWithFile(ResInfo[3].ImgName.c_str(), CGRectMake(0, 0, 20, 20));
|
||||
CCSprite *projectile = CCSprite::spriteWithFile(ResInfo[3].ResName.c_str());
|
||||
projectile->setPosition( ccp(20, winSize.height/2) );
|
||||
|
||||
// Determinie offset of location to projectile
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
// Original file name: Cocos2dSimpleGame_Res.ENU.tr3
|
||||
// Generated by TOPS Builder 1.2.3.235 Date:2010-10-12
|
||||
// Generated by TOPS Builder 1.2.3.235 Date:2010-10-19
|
||||
|
||||
|
||||
//$VERSION 60004
|
||||
|
@ -56,26 +56,54 @@ END
|
|||
IMAGEFOLDER ID ResFolder1001 FOLDERNAME $0052$006F$006F$0074$0028$0041$006C$006C$0029
|
||||
// 文件夹: Root(All)
|
||||
BEGIN
|
||||
BITMAP ID CloseNormal NOCOMPRESS HasAlphaData TRANSPARENTCOLOR $FFFFFFFF
|
||||
FileName $0043$006C$006F$0073$0065$004E$006F$0072$006D$0061$006C$002E$0070$006E$0067
|
||||
//CloseNormal.png
|
||||
IMAGEFOLDER ID ResFolder1010 FOLDERNAME $0048$0056$0047$0041$0052$0065$0073
|
||||
// Îļþ¼Ð: HVGARes
|
||||
BEGIN
|
||||
BITMAP ID CloseNormal NOCOMPRESS HasAlphaData TRANSPARENTCOLOR $FFFFFFFF
|
||||
FileName $0048$0056$0047$0041$0052$0065$0073$005C$0043$006C$006F$0073$0065$004E$006F$0072$006D$0061$006C$002E$0070$006E$0067
|
||||
//HVGARes\CloseNormal.png
|
||||
|
||||
BITMAP ID CloseSelected NOCOMPRESS HasAlphaData TRANSPARENTCOLOR $FFFFFFFF
|
||||
FileName $0043$006C$006F$0073$0065$0053$0065$006C$0065$0063$0074$0065$0064$002E$0070$006E$0067
|
||||
//CloseSelected.png
|
||||
BITMAP ID CloseSelected NOCOMPRESS HasAlphaData TRANSPARENTCOLOR $FFFFFFFF
|
||||
FileName $0048$0056$0047$0041$0052$0065$0073$005C$0043$006C$006F$0073$0065$0053$0065$006C$0065$0063$0074$0065$0064$002E$0070$006E$0067
|
||||
//HVGARes\CloseSelected.png
|
||||
|
||||
BITMAP ID Player NOCOMPRESS HasAlphaData TRANSPARENTCOLOR $FFFFFFFF
|
||||
FileName $0050$006C$0061$0079$0065$0072$002E$0070$006E$0067
|
||||
//Player.png
|
||||
BITMAP ID Player NOCOMPRESS HasAlphaData TRANSPARENTCOLOR $FFFFFFFF
|
||||
FileName $0048$0056$0047$0041$0052$0065$0073$005C$0050$006C$0061$0079$0065$0072$002E$0070$006E$0067
|
||||
//HVGARes\Player.png
|
||||
|
||||
BITMAP ID Projectile NOCOMPRESS HasAlphaData TRANSPARENTCOLOR $FFFFFFFF
|
||||
FileName $0050$0072$006F$006A$0065$0063$0074$0069$006C$0065$002E$0070$006E$0067
|
||||
//Projectile.png
|
||||
BITMAP ID Projectile NOCOMPRESS HasAlphaData TRANSPARENTCOLOR $FFFFFFFF
|
||||
FileName $0048$0056$0047$0041$0052$0065$0073$005C$0050$0072$006F$006A$0065$0063$0074$0069$006C$0065$002E$0070$006E$0067
|
||||
//HVGARes\Projectile.png
|
||||
|
||||
BITMAP ID Target NOCOMPRESS HasAlphaData TRANSPARENTCOLOR $FFFFFFFF
|
||||
FileName $0054$0061$0072$0067$0065$0074$002E$0070$006E$0067
|
||||
//Target.png
|
||||
BITMAP ID Target NOCOMPRESS HasAlphaData TRANSPARENTCOLOR $FFFFFFFF
|
||||
FileName $0048$0056$0047$0041$0052$0065$0073$005C$0054$0061$0072$0067$0065$0074$002E$0070$006E$0067
|
||||
//HVGARes\Target.png
|
||||
|
||||
END
|
||||
IMAGEFOLDER ID ResFolder1011 FOLDERNAME $0057$0056$0047$0041$0052$0065$0073
|
||||
// Îļþ¼Ð: WVGARes
|
||||
BEGIN
|
||||
BITMAP ID CloseNormal_WVGA NOCOMPRESS HasAlphaData TRANSPARENTCOLOR $FFFFFFFF
|
||||
FileName $0057$0056$0047$0041$0052$0065$0073$005C$0043$006C$006F$0073$0065$004E$006F$0072$006D$0061$006C$0040$0057$0056$0047$0041$002E$0070$006E$0067
|
||||
//WVGARes\CloseNormal@WVGA.png
|
||||
|
||||
BITMAP ID CloseSelected_WVGA NOCOMPRESS HasAlphaData TRANSPARENTCOLOR $FFFFFFFF
|
||||
FileName $0057$0056$0047$0041$0052$0065$0073$005C$0043$006C$006F$0073$0065$0053$0065$006C$0065$0063$0074$0065$0064$0040$0057$0056$0047$0041$002E$0070$006E$0067
|
||||
//WVGARes\CloseSelected@WVGA.png
|
||||
|
||||
BITMAP ID Player_WVGA NOCOMPRESS HasAlphaData TRANSPARENTCOLOR $FFFFFFFF
|
||||
FileName $0057$0056$0047$0041$0052$0065$0073$005C$0050$006C$0061$0079$0065$0072$0040$0057$0056$0047$0041$002E$0070$006E$0067
|
||||
//WVGARes\Player@WVGA.png
|
||||
|
||||
BITMAP ID Projectile_WVGA NOCOMPRESS HasAlphaData TRANSPARENTCOLOR $FFFFFFFF
|
||||
FileName $0057$0056$0047$0041$0052$0065$0073$005C$0050$0072$006F$006A$0065$0063$0074$0069$006C$0065$0040$0057$0056$0047$0041$002E$0070$006E$0067
|
||||
//WVGARes\Projectile@WVGA.png
|
||||
|
||||
BITMAP ID Target_WVGA NOCOMPRESS HasAlphaData TRANSPARENTCOLOR $FFFFFFFF
|
||||
FileName $0057$0056$0047$0041$0052$0065$0073$005C$0054$0061$0072$0067$0065$0074$0040$0057$0056$0047$0041$002E$0070$006E$0067
|
||||
//WVGARes\Target@WVGA.png
|
||||
|
||||
END
|
||||
END
|
||||
// raw data
|
||||
|
||||
|
|
|
@ -4,6 +4,6 @@
|
|||
// update the controls' trnaslation status.
|
||||
|
||||
// Original file name: Cocos2dSimpleGame_Res.ENU.tr3.tts
|
||||
// Generated by TOPS Builder 1.2.3.235 Date:2010-10-12
|
||||
// Generated by TOPS Builder 1.2.3.235 Date:2010-10-19
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
// Original file name: Cocos2dSimpleGame_Res.TR3
|
||||
// Generated by TOPS Builder 1.2.3.235 Date:2010-10-12
|
||||
// Generated by TOPS Builder 1.2.3.235 Date:2010-10-19
|
||||
|
||||
|
||||
#include "Cocos2dSimpleGame_Res.h"
|
||||
|
@ -58,26 +58,54 @@ END
|
|||
IMAGEFOLDER ID ResFolder1001 FOLDERNAME $0052$006F$006F$0074$0028$0041$006C$006C$0029
|
||||
// 文件夹: Root(All)
|
||||
BEGIN
|
||||
BITMAP ID CloseNormal NOCOMPRESS HasAlphaData TRANSPARENTCOLOR $FFFFFFFF
|
||||
FileName $0043$006C$006F$0073$0065$004E$006F$0072$006D$0061$006C$002E$0070$006E$0067
|
||||
//CloseNormal.png
|
||||
IMAGEFOLDER ID ResFolder1010 FOLDERNAME $0048$0056$0047$0041$0052$0065$0073
|
||||
// Îļþ¼Ð: HVGARes
|
||||
BEGIN
|
||||
BITMAP ID CloseNormal NOCOMPRESS HasAlphaData TRANSPARENTCOLOR $FFFFFFFF
|
||||
FileName $0048$0056$0047$0041$0052$0065$0073$005C$0043$006C$006F$0073$0065$004E$006F$0072$006D$0061$006C$002E$0070$006E$0067
|
||||
//HVGARes\CloseNormal.png
|
||||
|
||||
BITMAP ID CloseSelected NOCOMPRESS HasAlphaData TRANSPARENTCOLOR $FFFFFFFF
|
||||
FileName $0043$006C$006F$0073$0065$0053$0065$006C$0065$0063$0074$0065$0064$002E$0070$006E$0067
|
||||
//CloseSelected.png
|
||||
BITMAP ID CloseSelected NOCOMPRESS HasAlphaData TRANSPARENTCOLOR $FFFFFFFF
|
||||
FileName $0048$0056$0047$0041$0052$0065$0073$005C$0043$006C$006F$0073$0065$0053$0065$006C$0065$0063$0074$0065$0064$002E$0070$006E$0067
|
||||
//HVGARes\CloseSelected.png
|
||||
|
||||
BITMAP ID Player NOCOMPRESS HasAlphaData TRANSPARENTCOLOR $FFFFFFFF
|
||||
FileName $0050$006C$0061$0079$0065$0072$002E$0070$006E$0067
|
||||
//Player.png
|
||||
BITMAP ID Player NOCOMPRESS HasAlphaData TRANSPARENTCOLOR $FFFFFFFF
|
||||
FileName $0048$0056$0047$0041$0052$0065$0073$005C$0050$006C$0061$0079$0065$0072$002E$0070$006E$0067
|
||||
//HVGARes\Player.png
|
||||
|
||||
BITMAP ID Projectile NOCOMPRESS HasAlphaData TRANSPARENTCOLOR $FFFFFFFF
|
||||
FileName $0050$0072$006F$006A$0065$0063$0074$0069$006C$0065$002E$0070$006E$0067
|
||||
//Projectile.png
|
||||
BITMAP ID Projectile NOCOMPRESS HasAlphaData TRANSPARENTCOLOR $FFFFFFFF
|
||||
FileName $0048$0056$0047$0041$0052$0065$0073$005C$0050$0072$006F$006A$0065$0063$0074$0069$006C$0065$002E$0070$006E$0067
|
||||
//HVGARes\Projectile.png
|
||||
|
||||
BITMAP ID Target NOCOMPRESS HasAlphaData TRANSPARENTCOLOR $FFFFFFFF
|
||||
FileName $0054$0061$0072$0067$0065$0074$002E$0070$006E$0067
|
||||
//Target.png
|
||||
BITMAP ID Target NOCOMPRESS HasAlphaData TRANSPARENTCOLOR $FFFFFFFF
|
||||
FileName $0048$0056$0047$0041$0052$0065$0073$005C$0054$0061$0072$0067$0065$0074$002E$0070$006E$0067
|
||||
//HVGARes\Target.png
|
||||
|
||||
END
|
||||
IMAGEFOLDER ID ResFolder1011 FOLDERNAME $0057$0056$0047$0041$0052$0065$0073
|
||||
// Îļþ¼Ð: WVGARes
|
||||
BEGIN
|
||||
BITMAP ID CloseNormal_WVGA NOCOMPRESS HasAlphaData TRANSPARENTCOLOR $FFFFFFFF
|
||||
FileName $0057$0056$0047$0041$0052$0065$0073$005C$0043$006C$006F$0073$0065$004E$006F$0072$006D$0061$006C$0040$0057$0056$0047$0041$002E$0070$006E$0067
|
||||
//WVGARes\CloseNormal@WVGA.png
|
||||
|
||||
BITMAP ID CloseSelected_WVGA NOCOMPRESS HasAlphaData TRANSPARENTCOLOR $FFFFFFFF
|
||||
FileName $0057$0056$0047$0041$0052$0065$0073$005C$0043$006C$006F$0073$0065$0053$0065$006C$0065$0063$0074$0065$0064$0040$0057$0056$0047$0041$002E$0070$006E$0067
|
||||
//WVGARes\CloseSelected@WVGA.png
|
||||
|
||||
BITMAP ID Player_WVGA NOCOMPRESS HasAlphaData TRANSPARENTCOLOR $FFFFFFFF
|
||||
FileName $0057$0056$0047$0041$0052$0065$0073$005C$0050$006C$0061$0079$0065$0072$0040$0057$0056$0047$0041$002E$0070$006E$0067
|
||||
//WVGARes\Player@WVGA.png
|
||||
|
||||
BITMAP ID Projectile_WVGA NOCOMPRESS HasAlphaData TRANSPARENTCOLOR $FFFFFFFF
|
||||
FileName $0057$0056$0047$0041$0052$0065$0073$005C$0050$0072$006F$006A$0065$0063$0074$0069$006C$0065$0040$0057$0056$0047$0041$002E$0070$006E$0067
|
||||
//WVGARes\Projectile@WVGA.png
|
||||
|
||||
BITMAP ID Target_WVGA NOCOMPRESS HasAlphaData TRANSPARENTCOLOR $FFFFFFFF
|
||||
FileName $0057$0056$0047$0041$0052$0065$0073$005C$0054$0061$0072$0067$0065$0074$0040$0057$0056$0047$0041$002E$0070$006E$0067
|
||||
//WVGARes\Target@WVGA.png
|
||||
|
||||
END
|
||||
END
|
||||
// raw data
|
||||
|
||||
|
|
|
@ -1,12 +1,19 @@
|
|||
// Original file name: Cocos2dSimpleGame_Res.h
|
||||
// Generated by TOPS Builder 1.2.3.235 Date:2010-10-12
|
||||
// Generated by TOPS Builder 1.2.3.235 Date:2010-10-19
|
||||
|
||||
#define ResFolder1001 1001
|
||||
#define Form1002 1002
|
||||
#define CloseNormal 1003
|
||||
#define CloseSelected 1004
|
||||
#define Player 1005
|
||||
#define Projectile 1006
|
||||
#define Target 1007
|
||||
#define pew_pew_lei 1008
|
||||
#define background_music_aac 1009
|
||||
#define ResFolder1010 1010
|
||||
#define ResFolder1011 1011
|
||||
#define CloseNormal_WVGA 1012
|
||||
#define CloseSelected_WVGA 1013
|
||||
#define Player_WVGA 1014
|
||||
#define Projectile_WVGA 1015
|
||||
#define Target_WVGA 1016
|
||||
#define CloseNormal 1017
|
||||
#define CloseSelected 1018
|
||||
#define Player 1019
|
||||
#define Projectile 1020
|
||||
#define Target 1021
|
||||
|
|
|
@ -1 +1 @@
|
|||
f35a3780499b097bc387ffcdb69162536c13decf
|
||||
ed9d3da2bf2699a09bc7053935e5dca5008ba615
|
|
@ -18,11 +18,16 @@
|
|||
|
||||
#define COCOS2_ID_Form1002 1073742826 /*"Main"*/
|
||||
|
||||
#define COCOS2_ID_BITMAP_CloseNormal 1073742827
|
||||
#define COCOS2_ID_BITMAP_CloseSelected 1073742828
|
||||
#define COCOS2_ID_BITMAP_Player 1073742829
|
||||
#define COCOS2_ID_BITMAP_Projectile 1073742830
|
||||
#define COCOS2_ID_BITMAP_Target 1073742831
|
||||
#define COCOS2_ID_BITMAP_CloseNormal 1073742841
|
||||
#define COCOS2_ID_BITMAP_CloseSelected 1073742842
|
||||
#define COCOS2_ID_BITMAP_Player 1073742843
|
||||
#define COCOS2_ID_BITMAP_Projectile 1073742844
|
||||
#define COCOS2_ID_BITMAP_Target 1073742845
|
||||
#define COCOS2_ID_BITMAP_CloseNormal_WVGA 1073742836
|
||||
#define COCOS2_ID_BITMAP_CloseSelected_WVGA 1073742837
|
||||
#define COCOS2_ID_BITMAP_Player_WVGA 1073742838
|
||||
#define COCOS2_ID_BITMAP_Projectile_WVGA 1073742839
|
||||
#define COCOS2_ID_BITMAP_Target_WVGA 1073742840
|
||||
#define COCOS2_ID_RAWDATA_pew_pew_lei 1073742832
|
||||
#define COCOS2_ID_RAWDATA_background_music_aac 1073742833
|
||||
#endif
|
||||
|
|
|
@ -25,6 +25,11 @@ extern const BitmapType COCOS2_Bitmap_CloseSelected;
|
|||
extern const BitmapType COCOS2_Bitmap_Player;
|
||||
extern const BitmapType COCOS2_Bitmap_Projectile;
|
||||
extern const BitmapType COCOS2_Bitmap_Target;
|
||||
extern const BitmapType COCOS2_Bitmap_CloseNormal_WVGA;
|
||||
extern const BitmapType COCOS2_Bitmap_CloseSelected_WVGA;
|
||||
extern const BitmapType COCOS2_Bitmap_Player_WVGA;
|
||||
extern const BitmapType COCOS2_Bitmap_Projectile_WVGA;
|
||||
extern const BitmapType COCOS2_Bitmap_Target_WVGA;
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -7,13 +7,18 @@
|
|||
|
||||
using namespace cocos2d;
|
||||
|
||||
const T_ImageResInfo ResInfo[] =
|
||||
const T_ResourceInfo ResInfo[] =
|
||||
{
|
||||
{ "CloseNormal", COCOS2_ID_BITMAP_CloseNormal },
|
||||
{ "CloseSelected", COCOS2_ID_BITMAP_CloseSelected },
|
||||
{ "Player", COCOS2_ID_BITMAP_Player },
|
||||
{ "Projectile", COCOS2_ID_BITMAP_Projectile },
|
||||
{ "Target", COCOS2_ID_BITMAP_Target },
|
||||
{ "CloseNormal@WVGA", COCOS2_ID_BITMAP_CloseNormal_WVGA },
|
||||
{ "CloseSelected@WVGA", COCOS2_ID_BITMAP_CloseSelected_WVGA },
|
||||
{ "Player@WVGA", COCOS2_ID_BITMAP_Player_WVGA },
|
||||
{ "Projectile@WVGA", COCOS2_ID_BITMAP_Projectile_WVGA },
|
||||
{ "Target@WVGA", COCOS2_ID_BITMAP_Target_WVGA },
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -48,6 +48,10 @@ typedef enum
|
|||
SAX_STRING
|
||||
}CCSAXState;
|
||||
|
||||
typedef map<std::string, int> ResourceMap;
|
||||
static ResourceMap s_ResMap;
|
||||
static ResourceHandle s_HRes;
|
||||
|
||||
class CCDictMaker
|
||||
{
|
||||
public:
|
||||
|
@ -238,7 +242,7 @@ const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath)
|
|||
pRet->m_sString += s_pszResourcePath;
|
||||
pRet->m_sString += pszRelativePath;
|
||||
}
|
||||
return pRet->m_sString.c_str();
|
||||
return CCFileUtils::getDiffResolutionPath(pRet->m_sString.c_str());
|
||||
}
|
||||
const char *CCFileUtils::fullPathFromRelativeFile(const char *pszFilename, const char *pszRelativeFile)
|
||||
{
|
||||
|
@ -247,11 +251,176 @@ const char *CCFileUtils::fullPathFromRelativeFile(const char *pszFilename, const
|
|||
pRet->autorelease();
|
||||
pRet->m_sString = relativeFile.substr(0, relativeFile.rfind('/')+1);
|
||||
pRet->m_sString += pszFilename;
|
||||
return pRet->m_sString.c_str();
|
||||
return CCFileUtils::getDiffResolutionPath(pRet->m_sString.c_str());
|
||||
}
|
||||
NSDictionary<std::string, NSObject*> *CCFileUtils::dictionaryWithContentsOfFile(const char *pFileName)
|
||||
{
|
||||
CCDictMaker tMaker;
|
||||
return tMaker.dictionaryWithContentsOfFile(pFileName);
|
||||
}
|
||||
|
||||
const char* CCFileUtils::getDiffResolutionPath(const char *pszPath)
|
||||
{
|
||||
NSString *pRet = new NSString(pszPath);
|
||||
pRet->autorelease();
|
||||
|
||||
do
|
||||
{
|
||||
TApplication* pApp = TApplication::GetCurrentApplication();
|
||||
CCX_BREAK_IF(!pApp);
|
||||
|
||||
// get the Resolution
|
||||
int nScreenWidth = pApp->GetScreenWidth();
|
||||
int nScreenHeight = pApp->GetScreenHeight();
|
||||
|
||||
// it's default resolution, do nothing
|
||||
CCX_BREAK_IF(nScreenWidth == 320 && nScreenHeight == 480);
|
||||
|
||||
if (nScreenWidth == 480 && nScreenHeight == 800)
|
||||
{
|
||||
// it's WVGA
|
||||
CCX_BREAK_IF(pRet->m_sString.find("@WVGA") != -1);
|
||||
|
||||
std::string filePathWithoutExtension = pszPath;
|
||||
std::string extension = "";
|
||||
std::string filePath = pszPath;
|
||||
int nExPos = filePath.find_last_of(".");
|
||||
|
||||
if (nExPos != -1)
|
||||
{
|
||||
filePathWithoutExtension = filePath.substr(0, nExPos);
|
||||
extension = filePath.substr(nExPos);
|
||||
}
|
||||
|
||||
// new path, add "@WVGA" before the extension
|
||||
pRet->m_sString = filePathWithoutExtension + "@WVGA" + extension;
|
||||
|
||||
// not find the resource of new path,use the original path
|
||||
if (! CCFileUtils::isResourceExist(pRet->m_sString.c_str()))
|
||||
{
|
||||
pRet->m_sString = filePath;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// not support resolution
|
||||
NSAssert(0, "it's not supportted resolution.");
|
||||
}
|
||||
} while (0);
|
||||
|
||||
return pRet->m_sString.c_str();
|
||||
}
|
||||
|
||||
void CCFileUtils::setResourceEntry(const AppResourceEntry* pResEntry)
|
||||
{
|
||||
if (pResEntry)
|
||||
{
|
||||
s_HRes.setResourceEntry(pResEntry);
|
||||
}
|
||||
}
|
||||
|
||||
void CCFileUtils::setResourceInfo(const T_ResourceInfo ResInfo[], int nCount)
|
||||
{
|
||||
// first, clear the map before
|
||||
if (!s_ResMap.empty())
|
||||
{
|
||||
s_ResMap.clear();
|
||||
}
|
||||
|
||||
// second, insert the pairs
|
||||
for (int i = 0; i < nCount; ++i)
|
||||
{
|
||||
std::string name = (ResInfo[i]).ResName;
|
||||
std::string key = CCFileUtils::fullPathFromRelativePath(name.c_str());
|
||||
int nResID = (ResInfo[i]).nResID;
|
||||
|
||||
s_ResMap.insert(ResourceMap::value_type(key, nResID));
|
||||
}
|
||||
}
|
||||
|
||||
bool CCFileUtils::isResourceExist(const char* pszResName)
|
||||
{
|
||||
bool nRet = false;
|
||||
|
||||
TUChar FilePath[MAX_PATH] = {0};
|
||||
TUString::StrGBToUnicode(FilePath, (const Char *) pszResName);
|
||||
|
||||
if (EOS_IsFileExist(FilePath))
|
||||
{
|
||||
// find in the hardware
|
||||
nRet = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// find in the resource map
|
||||
ResourceMap::iterator iter;
|
||||
iter = s_ResMap.find(pszResName);
|
||||
|
||||
if (iter != s_ResMap.end())
|
||||
{
|
||||
nRet = true;
|
||||
}
|
||||
}
|
||||
|
||||
return nRet;
|
||||
}
|
||||
|
||||
const TBitmap* CCFileUtils::getBitmapByResName(const char* pszBmpName)
|
||||
{
|
||||
const TBitmap* pBmp = NULL;
|
||||
|
||||
do
|
||||
{
|
||||
ResourceMap::iterator iter;
|
||||
iter = s_ResMap.find(pszBmpName);
|
||||
CCX_BREAK_IF(iter == s_ResMap.end());
|
||||
|
||||
pBmp = s_HRes.LoadConstBitmap(iter->second);
|
||||
} while (0);
|
||||
|
||||
return pBmp;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
//
|
||||
// ResourceHandle
|
||||
//
|
||||
//////////////////////////////////////////////////
|
||||
ResourceHandle::ResourceHandle()
|
||||
:m_pResLib(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
ResourceHandle::~ResourceHandle()
|
||||
{
|
||||
release();
|
||||
}
|
||||
|
||||
void ResourceHandle::release()
|
||||
{
|
||||
if (m_pResLib)
|
||||
{
|
||||
delete m_pResLib;
|
||||
m_pResLib = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void ResourceHandle::setResourceEntry(const AppResourceEntry* pResEntry)
|
||||
{
|
||||
release();
|
||||
|
||||
m_pResLib = new TResourceLib(pResEntry);
|
||||
}
|
||||
|
||||
const TBitmap* ResourceHandle::LoadConstBitmap(int nResID)
|
||||
{
|
||||
const TBitmap* pResult = NULL;
|
||||
|
||||
if (m_pResLib)
|
||||
{
|
||||
pResult = m_pResLib->LoadConstBitmap(nResID);
|
||||
}
|
||||
|
||||
return pResult;
|
||||
}
|
||||
}//namespace cocos2d
|
||||
|
|
|
@ -29,8 +29,33 @@ THE SOFTWARE.
|
|||
#include <ssFile.h>
|
||||
#include "ccxCommon.h"
|
||||
#include "NSMutableDictionary.h"
|
||||
|
||||
class TBitmap;
|
||||
class TResourceLib;
|
||||
struct AppResourceEntry;
|
||||
|
||||
namespace cocos2d {
|
||||
|
||||
typedef struct
|
||||
{
|
||||
std::string ResName;
|
||||
int nResID;
|
||||
} T_ResourceInfo;
|
||||
|
||||
class ResourceHandle
|
||||
{
|
||||
public:
|
||||
ResourceHandle();
|
||||
~ResourceHandle();
|
||||
|
||||
void setResourceEntry(const AppResourceEntry* pResEntry);
|
||||
void release();
|
||||
const TBitmap* LoadConstBitmap(int nResID);
|
||||
|
||||
private:
|
||||
TResourceLib* m_pResLib;
|
||||
};
|
||||
|
||||
//! @brief Helper class to handle file operations
|
||||
class CCX_DLL CCFileUtils
|
||||
{
|
||||
|
@ -48,6 +73,8 @@ public:
|
|||
|
||||
/// @cond
|
||||
static const char* fullPathFromRelativeFile(const char *pszFilename, const char *pszRelativeFile);
|
||||
|
||||
static const char* getDiffResolutionPath(const char *pszPath);
|
||||
/// @endcond
|
||||
|
||||
/**
|
||||
|
@ -62,6 +89,33 @@ public:
|
|||
@param pszResourcePath The absolute resource path
|
||||
*/
|
||||
static void setResourcePath(const char *pszResourcePath);
|
||||
|
||||
/**
|
||||
@brief Set the Resource Entry
|
||||
@param pResEntry The pointer of the Application's ResourceEntry
|
||||
*/
|
||||
static void setResourceEntry(const AppResourceEntry* pResEntry);
|
||||
|
||||
/**
|
||||
@brief Set the Resource Info(ResourceName and ResID)
|
||||
@param ResInfo Array of T_ResourceInfo,contain all resource names and ids.
|
||||
@param nCount The count of the array elements.
|
||||
*/
|
||||
static void setResourceInfo(const T_ResourceInfo ResInfo[], int nCount);
|
||||
|
||||
/**
|
||||
@brief Whether the resource is exist or not.The function find the resource in hardware,if not find,it will find in resource map.
|
||||
@param pszResName The name of resource
|
||||
@return The return value is true if exist,otherwise return false.
|
||||
*/
|
||||
static bool isResourceExist(const char* pszResName);
|
||||
|
||||
/**
|
||||
@brief Get bitmap data from resource map
|
||||
@param pszBmpName The name of the bitmap
|
||||
@return If can find the name in resource map, return the pointer of the bitmap.Otherwise return NULL
|
||||
*/
|
||||
static const TBitmap* getBitmapByResName(const char* pszBmpName);
|
||||
};
|
||||
}//namespace cocos2d
|
||||
|
||||
|
|
|
@ -52,9 +52,6 @@ typedef struct
|
|||
int offset;
|
||||
}tImageSource;
|
||||
|
||||
typedef map<std::string, int> ResourceImageMap;
|
||||
static ResourceImageMap s_ImgMap;
|
||||
static ResourceHandle s_HRes;
|
||||
|
||||
// because we do not want to include "png.h" in CCXUIImage_uphone.h, so we implement
|
||||
// the function as a static function
|
||||
|
@ -139,21 +136,13 @@ bool UIImage::initWithContentsOfFile(const string &strPath, tImageFormat imageTy
|
|||
|
||||
if (!bRet)
|
||||
{
|
||||
// attempt load image from the ResourceImageMap when can't find the image file.
|
||||
ResourceImageMap::iterator iter;
|
||||
iter = s_ImgMap.find(strPath);
|
||||
|
||||
do
|
||||
// attempt load image from the ResourceMap when can't find the image file.
|
||||
const TBitmap* pBmp = CCFileUtils::getBitmapByResName(strPath.c_str());
|
||||
if (pBmp)
|
||||
{
|
||||
CCX_BREAK_IF(iter == s_ImgMap.end());
|
||||
|
||||
const TBitmap* pBmp = s_HRes.LoadConstBitmap(iter->second);
|
||||
|
||||
CCX_BREAK_IF(!pBmp);
|
||||
|
||||
initWithBitmap(pBmp);
|
||||
bRet = true;
|
||||
} while (0);
|
||||
}
|
||||
}
|
||||
|
||||
return bRet;
|
||||
|
@ -174,33 +163,6 @@ bool UIImage::isAlphaPixelFormat(void)
|
|||
return m_imageInfo.hasAlpha;
|
||||
}
|
||||
|
||||
void UIImage::setResourceEntry(const AppResourceEntry* pResEntry)
|
||||
{
|
||||
if (pResEntry)
|
||||
{
|
||||
s_HRes.setResourceEntry(pResEntry);
|
||||
}
|
||||
}
|
||||
|
||||
void UIImage::setImageResInfo(const T_ImageResInfo ResInfo[], int nCount)
|
||||
{
|
||||
// first, clear the map before
|
||||
if (!s_ImgMap.empty())
|
||||
{
|
||||
s_ImgMap.clear();
|
||||
}
|
||||
|
||||
// second, insert the pairs
|
||||
for (int i = 0; i < nCount; ++i)
|
||||
{
|
||||
std::string name = (ResInfo[i]).ImgName;
|
||||
std::string key = CCFileUtils::fullPathFromRelativePath(name.c_str());
|
||||
int nResID = (ResInfo[i]).nResID;
|
||||
|
||||
s_ImgMap.insert(ResourceImageMap::value_type(key, nResID));
|
||||
}
|
||||
}
|
||||
|
||||
// now, uphone only support premultiplied data
|
||||
// so, we only return true
|
||||
bool UIImage::isPremultipliedAlpha(void)
|
||||
|
@ -490,48 +452,4 @@ bool UIImage::initWithBitmap(const TBitmap* pBmp)
|
|||
|
||||
return bRet;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
//
|
||||
// ResourceHandle
|
||||
//
|
||||
//////////////////////////////////////////////////
|
||||
ResourceHandle::ResourceHandle()
|
||||
:m_pResLib(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
ResourceHandle::~ResourceHandle()
|
||||
{
|
||||
release();
|
||||
}
|
||||
|
||||
void ResourceHandle::release()
|
||||
{
|
||||
if (m_pResLib)
|
||||
{
|
||||
delete m_pResLib;
|
||||
m_pResLib = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void ResourceHandle::setResourceEntry(const AppResourceEntry* pResEntry)
|
||||
{
|
||||
release();
|
||||
|
||||
m_pResLib = new TResourceLib(pResEntry);
|
||||
}
|
||||
|
||||
const TBitmap* ResourceHandle::LoadConstBitmap(int nResID)
|
||||
{
|
||||
const TBitmap* pResult = NULL;
|
||||
|
||||
if (m_pResLib)
|
||||
{
|
||||
pResult = m_pResLib->LoadConstBitmap(nResID);
|
||||
}
|
||||
|
||||
return pResult;
|
||||
}
|
||||
|
||||
}//namespace cocos2d
|
||||
|
|
|
@ -30,9 +30,6 @@ THE SOFTWARE.
|
|||
#include "CCRenderTexture.h"
|
||||
|
||||
class TBitmap;
|
||||
class TResourceLib;
|
||||
struct AppResourceEntry;
|
||||
|
||||
namespace cocos2d {
|
||||
class CCXBitmapDC;
|
||||
|
||||
|
@ -46,26 +43,6 @@ typedef struct
|
|||
bool isPremultipliedAlpha;
|
||||
unsigned char *data;
|
||||
} tImageInfo;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
std::string ImgName;
|
||||
int nResID;
|
||||
} T_ImageResInfo;
|
||||
|
||||
class ResourceHandle
|
||||
{
|
||||
public:
|
||||
ResourceHandle();
|
||||
~ResourceHandle();
|
||||
|
||||
void setResourceEntry(const AppResourceEntry* pResEntry);
|
||||
void release();
|
||||
const TBitmap* LoadConstBitmap(int nResID);
|
||||
|
||||
private:
|
||||
TResourceLib* m_pResLib;
|
||||
};
|
||||
/// @endcond
|
||||
|
||||
/**
|
||||
|
@ -120,12 +97,6 @@ public:
|
|||
/** get the image data */
|
||||
unsigned char* getData(void);
|
||||
|
||||
/** set the Resource Entry */
|
||||
static void setResourceEntry(const AppResourceEntry* pResEntry);
|
||||
|
||||
/** set the images ResInfo(name and ResID) */
|
||||
static void setImageResInfo(const T_ImageResInfo ResInfo[], int nCount);
|
||||
|
||||
private:
|
||||
bool loadPng(const char* strFileName);
|
||||
bool loadPngFromStream(unsigned char *data, int nLength);
|
||||
|
|
Loading…
Reference in New Issue