Cocos2d手势

  • i4_283228
    了解作者
  • 24.5KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-04-20 01:44
    上传日期
为实现Cocos2d手势支持,改写的CCLayer、CCNode、CCGestureRecognizer三个源码类,可以参考我博客使用!
Cocos2d手势.zip
  • CCLayer.h
    8.6KB
  • CCGestureRecognizer.h
    1.6KB
  • CCNode.m
    26.2KB
  • CCLayer.m
    13.9KB
  • CCGestureRecognizer.m
    10.5KB
  • CCNode.h
    19KB
内容介绍
/* * 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 <availability.h rel='nofollow' onclick='return false;'> #import "Platforms/CCGL.h" #import "CCAction.h" #import "ccTypes.h" #import "CCTexture2D.h" #import "CCProtocols.h" #import "ccConfig.h" #import "Support/CCArray.h" #ifdef __IPHONE_OS_VERSION_MAX_ALLOWED @class CCGestureRecognizer; #endif 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 #ifdef __IPHONE_OS_VERSION_MAX_ALLOWED CCArray* gestureRecognizers_; CGSize touchableArea_; BOOL isTouchEnabled_; #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 between the Y axis and the left edge of the shape The default skewX angle is 0. Positive values distort the node in a CW direction. */ @property(nonatomic,readwrite,assign) float skewX; /** The Y skew angle of the node in degrees. This angle describes the shear distortion in the Y direction. Thus, it is the angle between the X axis and the bottom edge of the shape The default skewY angle is 0. Positive values distort the node in a CCW direction. */ @property(nonatomic,readwrite,assign) float skewY; /** The rotation (angle) of the node in degrees. 0 is the default rotation angle. Positive values rotate node CW. */ @property(nonatomic,readwrite,assign) float rotation; /** The scale factor of the node. 1.0 is the default scale factor. It modifies the X and Y scale at the same time. */ @property(nonatomic,readwrite,assign) float scale; /** The scale factor of the node. 1.0 is the default scale factor. It only modifies the X scale factor. */ @property(nonatomic,readwrite,assign) float scaleX; /** The scale factor of the node. 1.0 is the default scale factor. It only modifies the Y scale factor. */ @property(nonatomic,readwrite,assign) float scaleY; /** Position (x,y) of the node in points. (0,0) is the left-bottom corner. */ @property(nonatomic,readwrite,assign) CGPoint position; /** Position (x,y) of the node in points. (0,0) is the left-bottom corner. */ @property(nonatomic,readwrite,assign) CGPoint positionInPixels; /** A CCCamera object that lets you move the node using a gluLookAt */ @property(nonatomic,readonly) CCCamera* camera; /** Array of children */ @property(nonatomic,readonly) CCArray *children; /** A CCGrid object that is used when applying effects */ @property(nonatomic,readwrite,retain) CCGridBase* grid; /** Whether of not the node is visible. Default is YES */ @property(nonatomic,readwrite,assign) BOOL visible; /** anchorPoint is the point around which all transformations and positioning manipulations take place. It's like a pin in the node where it is "attached" to its parent. The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner. But you can use values higher than (1,1) and lower than (0,0) too. The default anchorPoint is (0,0). It starts in the bottom-left corner. CCSprite
评论
    相关推荐
    • Cocos2d Game
      I create a Cocos2d game
    • cocos2d富文本
      cocos2d 富文本实现 格式 [i:图片路径|-] [s:22|c:00ff00ff]***[-] [s:22]***[-] [l:item/1001]...[-] 随意组合嵌套
    • Cocos2d学习文档
      Cocos2d学习文档 适合新手 第1章-介绍cocos2d.pdf 第2章-开始学习.pdf 。。。。 第4章-你的第一个游戏(修正错误).pdf 。。。。
    • Cocos2d学习资料
      Cocos2D目录: 第一章:介绍Cocos2d 第二章: 开始学习 第三章: 基础知识 第四章: 你的第一个游戏(修正错误) 第五章: 游戏构成要素 第六章: 深入了解精灵(Sprite) 第七章: 横向滚屏射击游戏 第八章: 完成滚屏射击游戏...
    • cocos2d demo
      本资源是一个小的经典的cocos2d-x的demo,后续每周更新增加功能的版本
    • cocos2d精灵教程
      (译)cocos2d精灵教程:第一部分.pdf (译)cocos2d精灵教程:第三部分.pdf (译)cocos2d精灵教程:第二部分.pdf (译)cocos2d菜单教程:第一部分.pdf (译)cocos2d菜单教程:第三部分(完).pdf (译)...
    • cocos2d模板
      cocos2d-template-updated
    • Cocos2D文档
      Cocos2D开发参考文档 Cocos2D帮助文档
    • cocos2d实例
      cocos的一些实例代码,有助于初学者。
    • SIM800C_MQTT.rar
      使用SIM800C模块,使用MQTT协议,连接中国移动onenet平台,能实现数据的订阅、发布、存储等