Merge pull request #1255 from mustime/testlua

issue #1425: add ParticleTest to TestLua.
This commit is contained in:
James Chen 2012-08-29 03:06:42 -07:00
commit bff1615dbb
13 changed files with 1671 additions and 84 deletions

View File

@ -114,6 +114,8 @@ local function createTestLayer()
testLayer:addChild(menu, 1)
testLayer:registerScriptHandler(onEnterOrExit)
return testLayer
end

View File

@ -1,9 +0,0 @@
require "luaScript/helper"
Particle_Table =
{
}
Particle_Table = CreateEnumTable(Particle_Table)

View File

@ -149,8 +149,6 @@ function CreateTestMenu()
CloseMenu:addChild(CloseItem)
menuLayer:addChild(CloseMenu)
cclog("start")
-- add menu items for tests
local MainMenu = CCMenu:create()
for index, labelName in pairs(Test_Name) do

View File

@ -6,6 +6,8 @@ require "luaScript/ActionsProgressTest/ActionsProgressTest"
require "luaScript/EffectsTest/EffectsTest"
require "luaScript/ClickAndMoveTest/ClickAndMoveTest"
require "luaScript/RotateWorldTest/RotateWorldTest"
require "luaScript/ParticleTest/ParticleTest"
require "luaScript/PerformanceTest/PerformanceTest"
----------------------------------------------------

View File

@ -1 +1 @@
ee2f8b0551820a29e0c07b312b8af0c549978412
3f6262bf7aaf7588187cbc707cc0ef047ccce327

View File

@ -124,6 +124,9 @@ class CCNode : public CCObject
void removeFromParentAndCleanup(bool cleanup);
void removeChildByTag(int tag, bool cleanup);
void scheduleUpdate(void);
void unscheduleUpdate(void);
void registerScriptHandler(LUA_FUNCTION funcID);
void unregisterScriptHandler(void);

View File

@ -1,23 +1,23 @@
class CCParticleBatchNode : public CCNode, public CCTextureProtocol
{
public:
static CCParticleBatchNode* createWithTexture(CCTexture2D *tex, unsigned int capacity = kCCParticleDefaultCapacity);
static CCParticleBatchNode* create(const char* fileImage, unsigned int capacity = kCCParticleDefaultCapacity);
virtual void addChild(CCNode * child);
virtual void addChild(CCNode * child, int zOrder);
virtual void addChild(CCNode * child, int zOrder, int tag);
void addChild(CCNode * child);
void addChild(CCNode * child, int zOrder);
void addChild(CCNode * child, int zOrder, int tag);
void insertChild(CCParticleSystem* pSystem, unsigned int index);
virtual void removeChild(CCNode* child, bool cleanup);
virtual void reorderChild(CCNode * child, int zOrder);
void removeChild(CCNode* child, bool cleanup);
void reorderChild(CCNode * child, int zOrder);
void removeChildAtIndex(unsigned int index, bool doCleanup);
void removeAllChildrenWithCleanup(bool doCleanup);
void disableParticle(unsigned int particleIndex);
virtual CCTexture2D* getTexture(void);
virtual void setTexture(CCTexture2D *texture);
virtual void setBlendFunc(ccBlendFunc blendFunc);
virtual ccBlendFunc getBlendFunc(void);
CCTexture2D* getTexture(void);
void setTexture(CCTexture2D *texture);
void setBlendFunc(ccBlendFunc blendFunc);
ccBlendFunc getBlendFunc(void);
static CCParticleBatchNode* create(const char* fileImage, unsigned int capacity = kCCParticleDefaultCapacity);
static CCParticleBatchNode* createWithTexture(CCTexture2D *tex, unsigned int capacity = kCCParticleDefaultCapacity);
};

View File

@ -0,0 +1,55 @@
class CCParticleFire : public CCParticleSystemQuad
{
static CCParticleFire * create();
};
class CCParticleFireworks : public CCParticleSystemQuad
{
static CCParticleFireworks * create();
};
class CCParticleSun : public CCParticleSystemQuad
{
static CCParticleSun * create();
};
class CCParticleGalaxy : public CCParticleSystemQuad
{
static CCParticleGalaxy * create();
};
class CCParticleFlower : public CCParticleSystemQuad
{
static CCParticleFlower * create();
};
class CCParticleMeteor : public CCParticleSystemQuad
{
static CCParticleMeteor * create();
};
class CCParticleSpiral : public CCParticleSystemQuad
{
static CCParticleSpiral * create();
};
class CCParticleExplosion : public CCParticleSystemQuad
{
static CCParticleExplosion * create();
};
class CCParticleSmoke : public CCParticleSystemQuad
{
static CCParticleSmoke * create();
};
class CCParticleSnow : public CCParticleSystemQuad
{
static CCParticleSnow * create();
};
class CCParticleRain : public CCParticleSystemQuad
{
static CCParticleRain * create();
};

View File

@ -62,18 +62,48 @@ class CCParticleSystem : public CCNode
void updateQuadWithParticle(tCCParticle* particle, const CCPoint& newPosition);
void postStep();
unsigned int getParticleCount();
float getDuration();
void setDuration(float d);
CCPoint getSourcePosition();
void setSourcePosition(CCPoint pos);
CCPoint getPosVar();
void setPosVar(CCPoint pos);
float getLife();
void setLife(float life);
float getLifeVar();
void setLifeVar(float lifeVar);
float getAngle();
void setAngle(float angle);
float getAngleVar();
void setAngleVar(float angle);
float getStartSize();
void setStartSize(float size);
float getStartSizeVar();
void setStartSizeVar(float size);
float getEndSize();
void setEndSize(float size);
float getEndSizeVar();
void setEndSizeVar(float size);
void setStartColor(ccColor4F var);
const ccColor4F & getStartColor();
void setStartColorVar(ccColor4F var);
const ccColor4F & getStartColorVar();
void setEndColor(ccColor4F var);
const ccColor4F & getEndColor();
void setEndColorVar(ccColor4F var);
const ccColor4F & getEndColorVar();
void setStartSpin(float var);
float getStartSpin();
void setStartSpinVar(float var);
float getStartSpinVar();
void setEndSpin(float var);
float getEndSpin();
void setEndSpinVar(float var);
float getEndSpinVar();
void setEmissionRate(float rate);
float getEmissionRate();
unsigned int getTotalParticles();
@ -97,11 +127,20 @@ class CCParticleSystem : public CCNode
bool isBlendAdditive();
void setBlendAdditive(bool value);
CCParticleBatchNode* getBatchNode(void);
void setBatchNode(CCParticleBatchNode* node);
tCCPositionType getPositionType(void);
void setPositionType(tCCPositionType type);
bool initWithFile(const char* plistFile);
bool initWithTotalParticles(unsigned int number);
static CCParticleSystem * create(const char *plistFile);
};
class CCParticleSystemQuad : public CCParticleSystem
{
CCParticleSystemQuad(void);
void postStep();
void setDisplayFrame(CCSpriteFrame* spriteFrame);
void setTexture(CCTexture2D* texture);

View File

@ -34,6 +34,7 @@ $pfile "CCDictionary.pkg"
$pfile "CCNode.pkg"
$pfile "CCObject.pkg"
$pfile "CCParallaxNode.pkg"
$pfile "CCParticleExamples.pkg"
$pfile "CCParticleSystem.pkg"
$pfile "CCParticleBatchNode.pkg"
$pfile "CCPointExtension.pkg"

View File

@ -178,6 +178,17 @@ local CCObjectTypes = {
"CCTouch",
"CCTouchDispatcher",
"CCTouchHandler",
"CCParticleFire",
"CCParticleFireworks",
"CCParticleSun",
"CCParticleGalaxy",
"CCParticleFlower",
"CCParticleMeteor",
"CCParticleSpiral",
"CCParticleExplosion",
"CCParticleSmoke",
"CCParticleSnow",
"CCParticleRain",
}
-- register CCObject types

View File

@ -9,45 +9,39 @@ typedef unsigned short GLushort;
typedef unsigned int GLuint;
typedef float GLfloat;
typedef short GLshort;
typedef unsigned int GLenum;
typedef struct _ccColor3B
class ccColor3B
{
ccColor3B(void);
GLubyte r;
GLubyte g;
GLubyte b;
} ccColor3B;
};
static ccColor3B ccc3(const GLubyte r, const GLubyte g, const GLubyte b);
//! White color (255,255,255)
//static const ccColor3B ccWHITE={255,255,255};
//! Yellow color (255,255,0)
//static const ccColor3B ccYELLOW={255,255,0};
//! Blue color (0,0,255)
//static const ccColor3B ccBLUE={0,0,255};
//! Green Color (0,255,0)
//static const ccColor3B ccGREEN={0,255,0};
//! Red Color (255,0,0,)
//static const ccColor3B ccRED={255,0,0};
//! Magenta Color (255,0,255)
//static const ccColor3B ccMAGENTA={255,0,255};
//! Black Color (0,0,0)
//static const ccColor3B ccBLACK={0,0,0};
//! Orange Color (255,127,0)
//static const ccColor3B ccORANGE={255,127,0};
//! Gray Color (166,166,166)
//static const ccColor3B ccGRAY={166,166,166};
//$renaming ccc3(255, 255, 255) @ ccWHITE
//$renaming ccc3(255, 255, 0) @ ccYELLOW
//$renaming ccc3( 0, 0, 255) @ ccBLUE
//$renaming ccc3( 0, 255, 0) @ ccGREEN
//$renaming ccc3(255, 0, 0) @ ccRED
//$renaming ccc3(255, 0, 255) @ ccMAGENTA
//$renaming ccc3( 0, 0, 0) @ ccBLACK
//$renaming ccc3(255, 127, 0) @ ccORANGE
//$renaming ccc3(166, 166, 166) @ ccGRAY
/** RGBA color composed of 4 bytes
@since v0.8
*/
typedef struct _ccColor4B
class ccColor4B
{
ccColor4B(void);
GLubyte r;
GLubyte g;
GLubyte b;
GLubyte a;
} ccColor4B;
};
//! helper macro that creates an ccColor4B type
static ccColor4B ccc4(const GLubyte r, const GLubyte g, const GLubyte b, const GLubyte o);
@ -55,12 +49,14 @@ static ccColor4B ccc4(const GLubyte r, const GLubyte g, const GLubyte b, const G
/** RGBA color composed of 4 floats
@since v0.8
*/
typedef struct _ccColor4F {
class ccColor4F
{
ccColor4F(void);
GLfloat r;
GLfloat g;
GLfloat b;
GLfloat a;
} ccColor4F;
};
/** Returns a ccColor4F from a ccColor3B. Alpha will be 1.
@ -84,11 +80,12 @@ static bool ccc4FEqual(ccColor4F a, ccColor4F b);
/** A vertex composed of 2 floats: x, y
@since v0.8
*/
typedef struct _ccVertex2F
class ccVertex2F
{
ccVertex2F(void);
GLfloat x;
GLfloat y;
} ccVertex2F;
};
static ccVertex2F vertex2(const float x, const float y);
@ -96,86 +93,98 @@ static ccVertex2F vertex2(const float x, const float y);
/** A vertex composed of 2 floats: x, y
@since v0.8
*/
typedef struct _ccVertex3F
class ccVertex3F
{
ccVertex3F(void);
GLfloat x;
GLfloat y;
GLfloat z;
} ccVertex3F;
};
static ccVertex3F vertex3(const float x, const float y, const float z);
/** A texcoord composed of 2 floats: u, y
@since v0.8
*/
typedef struct _ccTex2F {
GLfloat u;
GLfloat v;
} ccTex2F;
class ccTex2F
{
ccTex2F(void);
GLfloat u;
GLfloat v;
};
static ccTex2F tex2(const float u, const float v);
//! Point Sprite component
typedef struct _ccPointSprite
class ccPointSprite
{
ccPointSprite(void);
ccVertex2F pos; // 8 bytes
ccColor4B color; // 4 bytes
GLfloat size; // 4 bytes
} ccPointSprite;
};
//! A 2D Quad. 4 * 2 floats
typedef struct _ccQuad2 {
class ccQuad2
{
ccQuad2(void);
ccVertex2F tl;
ccVertex2F tr;
ccVertex2F bl;
ccVertex2F br;
} ccQuad2;
};
//! A 3D Quad. 4 * 3 floats
typedef struct _ccQuad3 {
class ccQuad3
{
ccQuad3(void);
ccVertex3F bl;
ccVertex3F br;
ccVertex3F tl;
ccVertex3F tr;
} ccQuad3;
};
//! A 2D grid size
typedef struct _ccGridSize
class ccGridSize
{
ccGridSize(void);
int x;
int y;
} ccGridSize;
};
//! helper function to create a ccGridSize
static ccGridSize ccg(const int x, const int y);
//! a Point with a vertex point, a tex coord point and a color 4B
typedef struct _ccV2F_C4B_T2F
class ccV2F_C4B_T2F
{
ccV2F_C4B_T2F(void);
//! vertices (2F)
ccVertex2F vertices;
//! colors (4B)
ccColor4B colors;
//! tex coords (2F)
ccTex2F texCoords;
} ccV2F_C4B_T2F;
};
//! a Point with a vertex point, a tex coord point and a color 4F
typedef struct _ccV2F_C4F_T2F
class ccV2F_C4F_T2F
{
ccV2F_C4F_T2F(void);
//! vertices (2F)
ccVertex2F vertices;
//! colors (4F)
ccColor4F colors;
//! tex coords (2F)
ccTex2F texCoords;
} ccV2F_C4F_T2F;
};
//! a Point with a vertex point, a tex coord point and a color 4B
typedef struct _ccV3F_C4B_T2F
class ccV3F_C4B_T2F
{
ccV3F_C4B_T2F(void);
//! vertices (3F)
ccVertex3F vertices; // 12 bytes
// char __padding__[4];
@ -186,11 +195,12 @@ typedef struct _ccV3F_C4B_T2F
// tex coords (2F)
ccTex2F texCoords; // 8 byts
} ccV3F_C4B_T2F;
};
//! 4 ccVertex2FTex2FColor4B Quad
typedef struct _ccV2F_C4B_T2F_Quad
class ccV2F_C4B_T2F_Quad
{
ccV2F_C4B_T2F_Quad(void);
//! bottom left
ccV2F_C4B_T2F bl;
//! bottom right
@ -199,11 +209,12 @@ typedef struct _ccV2F_C4B_T2F_Quad
ccV2F_C4B_T2F tl;
//! top right
ccV2F_C4B_T2F tr;
} ccV2F_C4B_T2F_Quad;
};
//! 4 ccVertex3FTex2FColor4B
typedef struct _ccV3F_C4B_T2F_Quad
class ccV3F_C4B_T2F_Quad
{
ccV3F_C4B_T2F_Quad(void);
//! top left
ccV3F_C4B_T2F tl;
//! bottom left
@ -212,11 +223,12 @@ typedef struct _ccV3F_C4B_T2F_Quad
ccV3F_C4B_T2F tr;
//! bottom right
ccV3F_C4B_T2F br;
} ccV3F_C4B_T2F_Quad;
};
//! 4 ccVertex2FTex2FColor4F Quad
typedef struct _ccV2F_C4F_T2F_Quad
class ccV2F_C4F_T2F_Quad
{
ccV2F_C4F_T2F_Quad(void);
//! bottom left
ccV2F_C4F_T2F bl;
//! bottom right
@ -225,16 +237,15 @@ typedef struct _ccV2F_C4F_T2F_Quad
ccV2F_C4F_T2F tl;
//! top right
ccV2F_C4F_T2F tr;
} ccV2F_C4F_T2F_Quad;
};
//! Blend Function used for textures
typedef struct _ccBlendFunc
class ccBlendFunc
{
//! source blend function
ccBlendFunc(void);
GLenum src;
//! destination blend function
GLenum dst;
} ccBlendFunc;
};
// XXX: If any of these enums are edited and/or reordered, udpate CCTexture2D.m
//! Vertical text alignment type
@ -257,8 +268,9 @@ typedef enum
// types for animation in particle systems
// texture coordinates for a quad
typedef struct _ccT2F_Quad
class ccT2F_Quad
{
ccT2F_Quad(void);
//! bottom left
ccTex2F bl;
//! bottom right
@ -267,12 +279,13 @@ typedef struct _ccT2F_Quad
ccTex2F tl;
//! top right
ccTex2F tr;
} ccT2F_Quad;
};
// struct that holds the size in pixels, texture coordinates and delays for animated CCParticleSystemQuad
typedef struct
class ccAnimationFrameData
{
ccAnimationFrameData(void);
ccT2F_Quad texCoords;
float delay;
CCSize size;
} ccAnimationFrameData;
};