/libs/cocos2d/CCLayer.h

http://github.com/kstenerud/ObjectAL-for-iPhone · C Header · 144 lines · 42 code · 16 blank · 86 comment · 0 complexity · 0c930d8c2fc989a06acea6eb10501784 MD5 · raw file

  1. /*
  2. * cocos2d for iPhone: http://www.cocos2d-iphone.org
  3. *
  4. * Copyright (c) 2008-2010 Ricardo Quesada
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7. * of this software and associated documentation files (the "Software"), to deal
  8. * in the Software without restriction, including without limitation the rights
  9. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. * copies of the Software, and to permit persons to whom the Software is
  11. * furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in
  14. * all copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22. * THE SOFTWARE.
  23. *
  24. */
  25. #import <UIKit/UIKit.h>
  26. #import "CCProtocols.h"
  27. #import "CCNode.h"
  28. #import "CCTouchDelegateProtocol.h"
  29. //
  30. // CCLayer
  31. //
  32. /** CCLayer is a subclass of CCNode that implements the TouchEventsDelegate protocol.
  33. All features from CCNode are valid, plus the following new features:
  34. - It can receive iPhone Touches
  35. - It can receive Accelerometer input
  36. */
  37. @interface CCLayer : CCNode <UIAccelerometerDelegate, CCStandardTouchDelegate, CCTargetedTouchDelegate>
  38. {
  39. BOOL isTouchEnabled;
  40. BOOL isAccelerometerEnabled;
  41. }
  42. /** If isTouchEnabled, this method is called onEnter. Override it to change the
  43. way CCLayer receives touch events.
  44. ( Default: [[TouchDispatcher sharedDispatcher] addStandardDelegate:self priority:0] )
  45. Example:
  46. -(void) registerWithTouchDispatcher
  47. {
  48. [[TouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:INT_MIN+1 swallowsTouches:YES];
  49. }
  50. @since v0.8.0
  51. */
  52. -(void) registerWithTouchDispatcher;
  53. /** whether or not it will receive Touch events.
  54. You can enable / disable touch events with this property.
  55. Only the touches of this node will be affected. This "method" is not propagated to it's children.
  56. @since v0.8.1
  57. */
  58. @property(nonatomic,assign) BOOL isTouchEnabled;
  59. /** whether or not it will receive Accelerometer events
  60. You can enable / disable accelerometer events with this property.
  61. @since v0.8.1
  62. */
  63. @property(nonatomic,assign) BOOL isAccelerometerEnabled;
  64. @end
  65. //
  66. // CCColorLayer
  67. //
  68. /** CCColorLayer is a subclass of CCLayer that implements the CCRGBAProtocol protocol.
  69. All features from CCLayer are valid, plus the following new features:
  70. - opacity
  71. - RGB colors
  72. */
  73. @interface CCColorLayer : CCLayer <CCRGBAProtocol, CCBlendProtocol>
  74. {
  75. GLubyte opacity_;
  76. ccColor3B color_;
  77. GLfloat squareVertices[4 * 2];
  78. GLubyte squareColors[4 * 4];
  79. ccBlendFunc blendFunc_;
  80. }
  81. /** creates a CCLayer with color, width and height */
  82. + (id) layerWithColor: (ccColor4B)color width:(GLfloat)w height:(GLfloat)h;
  83. /** creates a CCLayer with color. Width and height are the window size. */
  84. + (id) layerWithColor: (ccColor4B)color;
  85. /** initializes a CCLayer with color, width and height */
  86. - (id) initWithColor:(ccColor4B)color width:(GLfloat)w height:(GLfloat)h;
  87. /** initializes a CCLayer with color. Width and height are the window size. */
  88. - (id) initWithColor:(ccColor4B)color;
  89. /** change width */
  90. -(void) changeWidth: (GLfloat)w;
  91. /** change height */
  92. -(void) changeHeight: (GLfloat)h;
  93. /** change width and height
  94. @since v0.8
  95. */
  96. -(void) changeWidth:(GLfloat)w height:(GLfloat)h;
  97. /** Opacity: conforms to CCRGBAProtocol protocol */
  98. @property (nonatomic,readonly) GLubyte opacity;
  99. /** Opacity: conforms to CCRGBAProtocol protocol */
  100. @property (nonatomic,readonly) ccColor3B color;
  101. /** BlendFunction. Conforms to CCBlendProtocol protocol */
  102. @property (nonatomic,readwrite) ccBlendFunc blendFunc;
  103. @end
  104. /** CCMultipleLayer is a CCLayer with the ability to multiplex it's children.
  105. Features:
  106. - It supports one or more children
  107. - Only one children will be active a time
  108. */
  109. @interface CCMultiplexLayer : CCLayer
  110. {
  111. unsigned int enabledLayer;
  112. NSMutableArray *layers;
  113. }
  114. /** creates a CCMultiplexLayer with one or more layers using a variable argument list. */
  115. +(id) layerWithLayers: (CCLayer*) layer, ... NS_REQUIRES_NIL_TERMINATION;
  116. /** initializes a MultiplexLayer with one or more layers using a variable argument list. */
  117. -(id) initWithLayers: (CCLayer*) layer vaList:(va_list) params;
  118. /** switches to a certain layer indexed by n.
  119. The current (old) layer will be removed from it's parent with 'cleanup:YES'.
  120. */
  121. -(void) switchTo: (unsigned int) n;
  122. /** release the current layer and switches to another layer indexed by n.
  123. The current (old) layer will be removed from it's parent with 'cleanup:YES'.
  124. */
  125. -(void) switchToAndReleaseMe: (unsigned int) n;
  126. @end