mirror of https://github.com/axmolengine/axmol.git
issue #5, add CCLayer.h, add @todo
This commit is contained in:
parent
46da55d4a0
commit
fdcbafda0f
|
@ -40,8 +40,6 @@ All features from CCNode are valid, plus the following features:
|
||||||
class CCAtlasNode : public CCNode, public CCRGBAProtocol, public CCTextureProtocol
|
class CCAtlasNode : public CCNode, public CCRGBAProtocol, public CCTextureProtocol
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
// texture atlas
|
|
||||||
//CCTextureAtlas *textureAtlas_;
|
|
||||||
|
|
||||||
// chars per row
|
// chars per row
|
||||||
int m_iItemsPerRow;
|
int m_iItemsPerRow;
|
||||||
|
@ -58,12 +56,6 @@ protected:
|
||||||
// height of each char
|
// height of each char
|
||||||
int m_iItemHeight;
|
int m_iItemHeight;
|
||||||
|
|
||||||
// blend function
|
|
||||||
//ccBlendFunc blendFunc_;
|
|
||||||
|
|
||||||
// texture RGBA.
|
|
||||||
//GLubyte opacity_;
|
|
||||||
//ccColor3B color_;
|
|
||||||
ccColor3B m_tColorUnmodified;
|
ccColor3B m_tColorUnmodified;
|
||||||
bool m_bOpacityModifyRGB;
|
bool m_bOpacityModifyRGB;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,140 @@
|
||||||
|
/****************************************************************************
|
||||||
|
Copyright (c) 2010 cocos2d-x.org
|
||||||
|
|
||||||
|
http://www.cocos2d-x.org
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __CCLAYER_H__
|
||||||
|
#define __CCLAYER_H__
|
||||||
|
|
||||||
|
#include "Cocos2dDefine.h"
|
||||||
|
#include "CCNode.h"
|
||||||
|
/// @todo CCTexture2D.h
|
||||||
|
//#include "CCProtocols.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// CCLayer
|
||||||
|
//
|
||||||
|
/** CCLayer is a subclass of CCNode that implements the TouchEventsDelegate protocol.
|
||||||
|
|
||||||
|
All features from CCNode are valid, plus the following new features:
|
||||||
|
- It can receive iPhone Touches
|
||||||
|
- It can receive Accelerometer input
|
||||||
|
*/
|
||||||
|
/// @todo public UIAccelerometerDelegate, public CCStandardTouchDelegate, public CCTargetedTouchDelegate
|
||||||
|
class CCLayer : public CCNode//, public UIAccelerometerDelegate, public CCStandardTouchDelegate, public CCTargetedTouchDelegate
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/** If isTouchEnabled, this method is called onEnter. Override it to change the
|
||||||
|
way CCLayer receives touch events.
|
||||||
|
( Default: [[TouchDispatcher sharedDispatcher] addStandardDelegate:self priority:0] )
|
||||||
|
Example:
|
||||||
|
-(void) registerWithTouchDispatcher
|
||||||
|
{
|
||||||
|
[[TouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:INT_MIN+1 swallowsTouches:YES];
|
||||||
|
}
|
||||||
|
@since v0.8.0
|
||||||
|
*/
|
||||||
|
void registerWithTouchDispatcher(void);
|
||||||
|
|
||||||
|
/** whether or not it will receive Touch events.
|
||||||
|
You can enable / disable touch events with this property.
|
||||||
|
Only the touches of this node will be affected. This "method" is not propagated to it's children.
|
||||||
|
@since v0.8.1
|
||||||
|
*/
|
||||||
|
CCX_DECLARE_VAR_READWRITE_INLINE(bool, m_bIsTouchEnabled, IsTouchEnabled)
|
||||||
|
/** whether or not it will receive Accelerometer events
|
||||||
|
You can enable / disable accelerometer events with this property.
|
||||||
|
@since v0.8.1
|
||||||
|
*/
|
||||||
|
CCX_DECLARE_VAR_READWRITE(bool, m_bIsAccelerometerEnabled, IsAccelerometerEnabled)
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// CCColorLayer
|
||||||
|
//
|
||||||
|
/** CCColorLayer is a subclass of CCLayer that implements the CCRGBAProtocol protocol.
|
||||||
|
|
||||||
|
All features from CCLayer are valid, plus the following new features:
|
||||||
|
- opacity
|
||||||
|
- RGB colors
|
||||||
|
*/
|
||||||
|
/// @todo public CCRGBAProtocol, public CCBlendProtocol
|
||||||
|
class CCColorLayer : public CCLayer //, public CCRGBAProtocol, public CCBlendProtocol
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
GLfloat m_fSquareVertices[4 * 2];
|
||||||
|
GLubyte m_cSquareColors[4 * 4];
|
||||||
|
|
||||||
|
public:
|
||||||
|
/** creates a CCLayer with color, width and height */
|
||||||
|
static void* layerWithColorWidthHeight(ccColor4B color, GLfloat width, GLfloat height);
|
||||||
|
/** creates a CCLayer with color. Width and height are the window size. */
|
||||||
|
static void* layerWithColor(ccColor4B color);
|
||||||
|
|
||||||
|
/** initializes a CCLayer with color, width and height */
|
||||||
|
void* initWithColorWidthHeight(ccColor4B color, GLfloat width, GLfloat height);
|
||||||
|
/** initializes a CCLayer with color. Width and height are the window size. */
|
||||||
|
void* initWithColor(ccColor4B color);
|
||||||
|
|
||||||
|
/** change width */
|
||||||
|
void changeWidth(GLfloat w);
|
||||||
|
/** change height */
|
||||||
|
void changeHeight(GLfloat h);
|
||||||
|
/** change width and height
|
||||||
|
@since v0.8
|
||||||
|
*/
|
||||||
|
void changeWidthAndHeight(GLfloat w ,GLfloat h);
|
||||||
|
|
||||||
|
/** Opacity: conforms to CCRGBAProtocol protocol */
|
||||||
|
CCX_DECLARE_VAR_READONLY(GLubyte, m_cOpacity, Opacity)
|
||||||
|
/** Opacity: conforms to CCRGBAProtocol protocol */
|
||||||
|
CCX_DECLARE_VAR_READONLY(ccColor3B, m_tColor, Color)
|
||||||
|
/** BlendFunction. Conforms to CCBlendProtocol protocol */
|
||||||
|
CCX_DECLARE_VAR_READWRITE(ccBlendFunc, m_tBlendFunc, BlendFunc)
|
||||||
|
};
|
||||||
|
|
||||||
|
/** CCMultipleLayer is a CCLayer with the ability to multiplex it's children.
|
||||||
|
Features:
|
||||||
|
- It supports one or more children
|
||||||
|
- Only one children will be active a time
|
||||||
|
*/
|
||||||
|
class CCMultiplexLayer : public CCLayer
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
unsigned int enabledLayer;
|
||||||
|
NSMutableArray *layers;
|
||||||
|
public:
|
||||||
|
/** creates a CCMultiplexLayer with one or more layers using a variable argument list. */
|
||||||
|
static void* layerWithLayers(CCLayer* layer, ... );
|
||||||
|
/** initializes a MultiplexLayer with one or more layers using a variable argument list. */
|
||||||
|
void* initWithLayers(CCLayer* layer, va_list params);
|
||||||
|
/** switches to a certain layer indexed by n.
|
||||||
|
The current (old) layer will be removed from it's parent with 'cleanup:YES'.
|
||||||
|
*/
|
||||||
|
void switchTo(unsigned int n);
|
||||||
|
/** release the current layer and switches to another layer indexed by n.
|
||||||
|
The current (old) layer will be removed from it's parent with 'cleanup:YES'.
|
||||||
|
*/
|
||||||
|
void switchToAndReleaseMe(unsigned int n);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -96,62 +96,6 @@ class CCNode{
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// rotation angle
|
|
||||||
//float m_fRotation;
|
|
||||||
|
|
||||||
// scaling factors
|
|
||||||
//float m_fScaleX, m_fScaleY;
|
|
||||||
|
|
||||||
// position of the node
|
|
||||||
//CGPoint m_tPosition;
|
|
||||||
|
|
||||||
// is visible
|
|
||||||
//bool m_bIsVisible;
|
|
||||||
|
|
||||||
// anchor point in pixels
|
|
||||||
//CGPoint m_tAnchorPointInPixels;
|
|
||||||
|
|
||||||
// anchor point normalized
|
|
||||||
//CGPoint m_tAnchorPoint;
|
|
||||||
|
|
||||||
// If true the transformtions will be relative to (-transform.x, -transform.y).
|
|
||||||
// Sprites, Labels and any other "small" object uses it.
|
|
||||||
// Scenes, Layers and other "whole screen" object don't use it.
|
|
||||||
//bool m_bIsRelativeAnchorPoint;
|
|
||||||
|
|
||||||
// untransformed size of the node
|
|
||||||
//CGSize m_tContentSize;
|
|
||||||
|
|
||||||
// transform
|
|
||||||
//CGAffineTransform m_tTransform, m_tInverse;
|
|
||||||
|
|
||||||
// openGL real Z vertex
|
|
||||||
//float m_fVertexZ;
|
|
||||||
|
|
||||||
// a Camera
|
|
||||||
//CCCamera * m_pCamera;
|
|
||||||
|
|
||||||
// a Grid
|
|
||||||
//CCGridBase * m_pGrid;
|
|
||||||
|
|
||||||
// z-order value
|
|
||||||
//int m_iZOrder;
|
|
||||||
|
|
||||||
// array of children
|
|
||||||
//NSMutableArray * m_pChildren;
|
|
||||||
|
|
||||||
// weakref to parent
|
|
||||||
//CCNode * m_pParent;
|
|
||||||
|
|
||||||
// a tag. any number you want to assign to the node
|
|
||||||
//int m_iTag;
|
|
||||||
|
|
||||||
// user data field
|
|
||||||
//void *m_pUserData;
|
|
||||||
|
|
||||||
// Is running
|
|
||||||
//bool m_bIsRunning;
|
|
||||||
|
|
||||||
#ifdef CCX_NODE_TRANSFORM_USING_AFFINE_MATRIX
|
#ifdef CCX_NODE_TRANSFORM_USING_AFFINE_MATRIX
|
||||||
GLfloat m_pTransformGL[16];
|
GLfloat m_pTransformGL[16];
|
||||||
#endif
|
#endif
|
||||||
|
@ -378,13 +322,14 @@ public:
|
||||||
@since v0.7.1
|
@since v0.7.1
|
||||||
@return An Action pointer
|
@return An Action pointer
|
||||||
*/
|
*/
|
||||||
// CCAction* runAction(CCAction* action);
|
|
||||||
|
/// @todo CCAction* runAction(CCAction* action);
|
||||||
|
|
||||||
/** Removes all actions from the running action list */
|
/** Removes all actions from the running action list */
|
||||||
void stopAllActions(void);
|
void stopAllActions(void);
|
||||||
|
|
||||||
/** Removes an action from the running action list */
|
/** Removes an action from the running action list */
|
||||||
// void stopAction(CCAction* action);
|
/// @todo void stopAction(CCAction* action);
|
||||||
|
|
||||||
/** Removes an action from the running action list given its tag
|
/** Removes an action from the running action list given its tag
|
||||||
@since v0.7.1
|
@since v0.7.1
|
||||||
|
@ -395,7 +340,7 @@ public:
|
||||||
@since v0.7.1
|
@since v0.7.1
|
||||||
@return the Action the with the given tag
|
@return the Action the with the given tag
|
||||||
*/
|
*/
|
||||||
// CCAction* getActionByTag(int tag);
|
/// @todo CCAction* getActionByTag(int tag);
|
||||||
|
|
||||||
/** Returns the numbers of actions that are running plus the ones that are schedule to run (actions in actionsToAdd and actions arrays).
|
/** Returns the numbers of actions that are running plus the ones that are schedule to run (actions in actionsToAdd and actions arrays).
|
||||||
* Composable actions are counted as 1 action. Example:
|
* Composable actions are counted as 1 action. Example:
|
||||||
|
@ -408,7 +353,7 @@ public:
|
||||||
// timers
|
// timers
|
||||||
|
|
||||||
/** check whether a selector is scheduled. */
|
/** check whether a selector is scheduled. */
|
||||||
// bool isScheduled(SEL selector);
|
/// @todo bool isScheduled(SEL selector);
|
||||||
|
|
||||||
/** schedules the "update" method. It will use the order number 0. This method will be called every frame.
|
/** schedules the "update" method. It will use the order number 0. This method will be called every frame.
|
||||||
Scheduled methods with a lower order value will be called before the ones that have a higher order value.
|
Scheduled methods with a lower order value will be called before the ones that have a higher order value.
|
||||||
|
@ -435,16 +380,16 @@ public:
|
||||||
/** schedules a selector.
|
/** schedules a selector.
|
||||||
The scheduled selector will be ticked every frame
|
The scheduled selector will be ticked every frame
|
||||||
*/
|
*/
|
||||||
// void schedule(SEL selector);
|
/// @todo void schedule(SEL selector);
|
||||||
|
|
||||||
/** schedules a custom selector with an interval time in seconds.
|
/** schedules a custom selector with an interval time in seconds.
|
||||||
If time is 0 it will be ticked every frame.
|
If time is 0 it will be ticked every frame.
|
||||||
If tiem is 0, it is recommended to use 'scheduleUpdate' instead.
|
If tiem is 0, it is recommended to use 'scheduleUpdate' instead.
|
||||||
*/
|
*/
|
||||||
// void schedule(SEL selector, ccTime seconds);
|
/// @todo void schedule(SEL selector, ccTime seconds);
|
||||||
|
|
||||||
/** unschedules a custom selector.*/
|
/** unschedules a custom selector.*/
|
||||||
// void unschedule(SEL selector);
|
/// @todo void unschedule(SEL selector);
|
||||||
|
|
||||||
/** unschedule all scheduled selectors: custom selectors, and the 'update' selector.
|
/** unschedule all scheduled selectors: custom selectors, and the 'update' selector.
|
||||||
Actions are not affected by this method.
|
Actions are not affected by this method.
|
||||||
|
@ -467,22 +412,22 @@ public:
|
||||||
/** Returns the local affine transform matrix
|
/** Returns the local affine transform matrix
|
||||||
@since v0.7.1
|
@since v0.7.1
|
||||||
*/
|
*/
|
||||||
// CGAffineTransform nodeToParentTransform(void);
|
/// @todo CGAffineTransform nodeToParentTransform(void);
|
||||||
|
|
||||||
/** Returns the inverse local affine transform matrix
|
/** Returns the inverse local affine transform matrix
|
||||||
@since v0.7.1
|
@since v0.7.1
|
||||||
*/
|
*/
|
||||||
// CGAffineTransform parentToNodeTransform(void);
|
/// @todo CGAffineTransform parentToNodeTransform(void);
|
||||||
|
|
||||||
/** Retrusn the world affine transform matrix
|
/** Retrusn the world affine transform matrix
|
||||||
@since v0.7.1
|
@since v0.7.1
|
||||||
*/
|
*/
|
||||||
// CGAffineTransform nodeToWorldTransform(void);
|
/// @todo CGAffineTransform nodeToWorldTransform(void);
|
||||||
|
|
||||||
/** Returns the inverse world affine transform matrix
|
/** Returns the inverse world affine transform matrix
|
||||||
@since v0.7.1
|
@since v0.7.1
|
||||||
*/
|
*/
|
||||||
// CGAffineTransform worldToNodeTransform(void);
|
/// @todo CGAffineTransform worldToNodeTransform(void);
|
||||||
|
|
||||||
/** converts a world coordinate to local coordinate
|
/** converts a world coordinate to local coordinate
|
||||||
@since v0.7.1
|
@since v0.7.1
|
||||||
|
@ -505,12 +450,12 @@ public:
|
||||||
/** convenience methods which take a UITouch instead of CGPoint
|
/** convenience methods which take a UITouch instead of CGPoint
|
||||||
@since v0.7.1
|
@since v0.7.1
|
||||||
*/
|
*/
|
||||||
// CGPoint convertTouchToNodeSpace(UITouch * touch);
|
/// @todo CGPoint convertTouchToNodeSpace(UITouch * touch);
|
||||||
|
|
||||||
/** converts a UITouch (world coordinates) into a local coordiante. This method is AR (Anchor Relative).
|
/** converts a UITouch (world coordinates) into a local coordiante. This method is AR (Anchor Relative).
|
||||||
@since v0.7.1
|
@since v0.7.1
|
||||||
*/
|
*/
|
||||||
// CGPoint convertTouchToNodeSpaceAR:(UITouch * touch);
|
/// @todo CGPoint convertTouchToNodeSpaceAR:(UITouch * touch);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
/****************************************************************************
|
||||||
|
Copyright (c) 2010 cocos2d-x.org
|
||||||
|
|
||||||
|
http://www.cocos2d-x.org
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "CCLayer.h"
|
||||||
|
|
||||||
|
using namespace std;
|
Loading…
Reference in New Issue