/* * cocos2d for iPhone: http://www.cocos2d-iphone.org * * Copyright (c) 2009 Valentin Milea * * Copyright (c) 2008-2010 Ricardo Quesada * Copyright (c) 2011 Zynga Inc. * * 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. */ #import #import "Platforms/CCGL.h" #import "CCAction.h" #import "ccTypes.h" #import "CCTexture2D.h" #import "CCProtocols.h" #import "ccConfig.h" #import "Support/CCArray.h" enum { kCCNodeTagInvalid = -1, }; @class CCCamera; @class CCGridBase; /** CCNode is the main element. Anything thats gets drawn or contains things that get drawn is a CCNode. The most popular CCNodes are: CCScene, CCLayer, CCSprite, CCMenu. The main features of a CCNode are: - They can contain other CCNode nodes (addChild, getChildByTag, removeChild, etc) - They can schedule periodic callback (schedule, unschedule, etc) - They can execute actions (runAction, stopAction, etc) Some CCNode nodes provide extra functionality for them or their children. Subclassing a CCNode usually means (one/all) of: - overriding init to initialize resources and schedule callbacks - create callbacks to handle the advancement of time - overriding draw to render the node Features of CCNode: - position - scale (x, y) - rotation (in degrees, clockwise) - CCCamera (an interface to gluLookAt ) - CCGridBase (to do mesh transformations) - anchor point - size - visible - z-order - openGL z position Default values: - rotation: 0 - position: (x=0,y=0) - scale: (x=1,y=1) - contentSize: (x=0,y=0) - anchorPoint: (x=0,y=0) Limitations: - A CCNode is a "void" object. It doesn't have a texture Order in transformations with grid disabled -# The node will be translated (position) -# The node will be rotated (rotation) -# The node will be scaled (scale) -# The node will be moved according to the camera values (camera) Order in transformations with grid enabled -# The node will be translated (position) -# The node will be rotated (rotation) -# The node will be scaled (scale) -# The grid will capture the screen -# The node will be moved according to the camera values (camera) -# The grid will render the captured screen Camera: - Each node has a camera. By default it points to the center of the CCNode. */ @interface CCNode : NSObject { // rotation angle float rotation_; // scaling factors float scaleX_, scaleY_; // position of the node CGPoint position_; CGPoint positionInPixels_; // skew angles float skewX_, skewY_; // is visible BOOL visible_; // anchor point in pixels CGPoint anchorPointInPixels_; // anchor point normalized CGPoint anchorPoint_; // If YES 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 isRelativeAnchorPoint_; // untransformed size of the node CGSize contentSize_; CGSize contentSizeInPixels_; // transform CGAffineTransform transform_, inverse_; #if CC_NODE_TRANSFORM_USING_AFFINE_MATRIX GLfloat transformGL_[16]; #endif // openGL real Z vertex float vertexZ_; // a Camera CCCamera *camera_; // a Grid CCGridBase *grid_; // z-order value NSInteger zOrder_; // array of children CCArray *children_; // weakref to parent CCNode *parent_; // a tag. any number you want to assign to the node NSInteger tag_; // user data field void *userData_; // Is running BOOL isRunning_; // To reduce memory, place BOOLs that are not properties here: BOOL isTransformDirty_:1; BOOL isInverseDirty_:1; #if CC_NODE_TRANSFORM_USING_AFFINE_MATRIX BOOL isTransformGLDirty_:1; #endif } /** The z order of the node relative to it's "brothers": children of the same parent */ @property(nonatomic,readonly) NSInteger zOrder; /** The real openGL Z vertex. Differences between openGL Z vertex and cocos2d Z order: - OpenGL Z modifies the Z vertex, and not the Z order in the relation between parent-children - OpenGL Z might require to set 2D projection - cocos2d Z order works OK if all the nodes uses the same openGL Z vertex. eg: vertexZ = 0 @warning: Use it at your own risk since it might break the cocos2d parent-children z order @since v0.8 */ @property (nonatomic,readwrite) float vertexZ; /** The X skew angle of the node in degrees. This angle describes the shear distortion in the X direction. Thus, it is the angle be
/*
 * cocos2d for iPhone: http://www.cocos2d-iphone.org
 *
 * Copyright (c) 2010 Ricardo Quesada
 * Copyright (c) 2011 Zynga Inc.
 * 
 * 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.
 *
 *
 * File autogenerated with Xcode. Adapted for cocos2d needs.
 */

// Only compile this code on iOS. These files should NOT be included on your Mac project.
// But in case they are included, it won't be compiled.
#import <Availability.h>
#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED

#import <QuartzCore/QuartzCore.h>

#import <OpenGLES/EAGL.h>
#import <OpenGLES/EAGLDrawable.h>

@protocol ESRenderer <NSObject>

- (id) initWithDepthFormat:(unsigned int)depthFormat withPixelFormat:(unsigned int)pixelFormat withSharegroup:(EAGLSharegroup*)sharegroup withMultiSampling:(BOOL) multiSampling withNumberOfSamples:(unsigned int) requestedSamples;

- (BOOL) resizeFromLayer:(CAEAGLLayer *)layer;

- (EAGLContext*) context;
- (CGSize) backingSize;

- (unsigned int) colorRenderBuffer;
- (unsigned int) defaultFrameBuffer;
- (unsigned int) msaaFrameBuffer;
- (unsigned int) msaaColorBuffer;
@end

#endif // __IPHONE_OS_VERSION_MAX_ALLOWED
form; /** Returns the inverse world affine transform matrix. The matrix is in Pixels. @since v0.7.1 */ - (CGAffineTransform)worldToNodeTransform; /** Converts a Point to node (local) space coordinates. The result is in Points. @since v0.7.1 */ - (CGPoint)convertToNodeSpace:(CGPoint)worldPoint; /** Converts a Point to world space coordinates. The result is in Points. @since v0.7.1 */ - (CGPoint)convertToWorldSpace:(CGPoint)nodePoint; /** Converts a Point to node (local) space coordinates. The result is in Points. treating the returned/received node point as anchor relative. @since v0.7.1 */ - (CGPoint)convertToNodeSpaceAR:(CGPoint)worldPoint; /** Converts a local Point to world space coordinates.The result is in Points. treating the returned/received node point as anchor relative. @since v0.7.1 */ - (CGPoint)convertToWorldSpaceAR:(CGPoint)nodePoint; #ifdef __IPHONE_OS_VERSION_MAX_ALLOWED /** Converts a UITouch to node (local) space coordinates. The result is in Points. @since v0.7.1 */ - (CGPoint)convertTouchToNodeSpace:(UITouch *)touch; /** Converts a UITouch to node (local) space coordinates. The result is in Points. This method is AR (Anchor Relative).. @since v0.7.1 */ - (CGPoint)convertTouchToNodeSpaceAR:(UITouch *)touch; #endif // __IPHONE_OS_VERSION_MAX_ALLOWED @end