/libs/cocos2d/CCProtocols.h

http://github.com/kstenerud/ObjectAL-for-iPhone · C Header · 112 lines · 32 code · 13 blank · 67 comment · 0 complexity · d8343a1393c9072ab805b254831ffcdb 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. #import "ccTypes.h"
  25. #import "CCTexture2D.h"
  26. #pragma mark -
  27. #pragma mark CCRGBAProtocol
  28. /// CC RGBA protocol
  29. @protocol CCRGBAProtocol <NSObject>
  30. /** sets Color
  31. @since v0.8
  32. */
  33. -(void) setColor:(ccColor3B)color;
  34. /** returns the color
  35. @since v0.8
  36. */
  37. -(ccColor3B) color;
  38. /// returns the opacity
  39. -(GLubyte) opacity;
  40. /** sets the opacity.
  41. @warning If the the texture has premultiplied alpha then, the R, G and B channels will be modifed.
  42. Values goes from 0 to 255, where 255 means fully opaque.
  43. */
  44. -(void) setOpacity: (GLubyte) opacity;
  45. @optional
  46. /** sets the premultipliedAlphaOpacity property.
  47. If set to NO then opacity will be applied as: glColor(R,G,B,opacity);
  48. If set to YES then oapcity will be applied as: glColor(opacity, opacity, opacity, opacity );
  49. Textures with premultiplied alpha will have this property by default on YES. Otherwise the default value is NO
  50. @since v0.8
  51. */
  52. -(void) setOpacityModifyRGB:(BOOL)boolean;
  53. /** returns whether or not the opacity will be applied using glColor(R,G,B,opacity) or glColor(opacity, opacity, opacity, opacity);
  54. @since v0.8
  55. */
  56. -(BOOL) doesOpacityModifyRGB;
  57. @end
  58. #pragma mark -
  59. #pragma mark CCBlendProtocol
  60. /**
  61. You can specify the blending fuction.
  62. @since v0.99.0
  63. */
  64. @protocol CCBlendProtocol <NSObject>
  65. /** set the source blending function for the texture */
  66. -(void) setBlendFunc:(ccBlendFunc)blendFunc;
  67. /** returns the blending function used for the texture */
  68. -(ccBlendFunc) blendFunc;
  69. @end
  70. #pragma mark -
  71. #pragma mark CCTextureProtocol
  72. /** CCNode objects that uses a Texture2D to render the images.
  73. The texture can have a blending function.
  74. If the texture has alpha premultiplied the default blending function is:
  75. src=GL_ONE dst= GL_ONE_MINUS_SRC_ALPHA
  76. else
  77. src=GL_SRC_ALPHA dst= GL_ONE_MINUS_SRC_ALPHA
  78. But you can change the blending funtion at any time.
  79. @since v0.8.0
  80. */
  81. @protocol CCTextureProtocol <CCBlendProtocol>
  82. /** returns the used texture */
  83. -(CCTexture2D*) texture;
  84. /** sets a new texture. it will be retained */
  85. -(void) setTexture:(CCTexture2D*)texture;
  86. @end
  87. #pragma mark -
  88. #pragma mark CCLabelProtocol
  89. /** Common interface for Labels */
  90. @protocol CCLabelProtocol <NSObject>
  91. /** sets a new label using an NSString */
  92. -(void) setString:(NSString*)label;
  93. @optional
  94. /** sets a new label using a CString.
  95. It is faster than setString since it doesn't require to alloc/retain/release an NString object.
  96. @since v0.99.0
  97. */
  98. -(void) setCString:(char*)label;
  99. @end