/libs/cocos2d/CCAtlasNode.h

http://github.com/kstenerud/ObjectAL-for-iPhone · C Header · 86 lines · 23 code · 15 blank · 48 comment · 0 complexity · 6a39657316be514369c3ed5a0126d388 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 "CCTextureAtlas.h"
  25. #import "CCNode.h"
  26. #import "CCProtocols.h"
  27. /** CCAtlasNode is a subclass of CCNode that implements the CCRGBAProtocol and
  28. CCTextureProtocol protocol
  29. It knows how to render a TextureAtlas object.
  30. If you are going to render a TextureAtlas consider subclassing CCAtlasNode (or a subclass of CCAtlasNode)
  31. All features from CCNode are valid, plus the following features:
  32. - opacity and RGB colors
  33. */
  34. @interface CCAtlasNode : CCNode <CCRGBAProtocol, CCTextureProtocol> {
  35. // texture atlas
  36. CCTextureAtlas *textureAtlas_;
  37. // chars per row
  38. int itemsPerRow_;
  39. // chars per column
  40. int itemsPerColumn_;
  41. // width of each char
  42. int itemWidth_;
  43. // height of each char
  44. int itemHeight_;
  45. // blend function
  46. ccBlendFunc blendFunc_;
  47. // texture RGBA.
  48. GLubyte opacity_;
  49. ccColor3B color_;
  50. ccColor3B colorUnmodified_;
  51. BOOL opacityModifyRGB_;
  52. }
  53. /** conforms to CCTextureProtocol protocol */
  54. @property (nonatomic,readwrite,retain) CCTextureAtlas *textureAtlas;
  55. /** conforms to CCTextureProtocol protocol */
  56. @property (nonatomic,readwrite) ccBlendFunc blendFunc;
  57. /** conforms to CCRGBAProtocol protocol */
  58. @property (nonatomic,readwrite) GLubyte opacity;
  59. /** conforms to CCRGBAProtocol protocol */
  60. @property (nonatomic,readwrite) ccColor3B color;
  61. /** creates a CCAtlasNode with an Atlas file the width and height of each item and the quantity of items to render*/
  62. +(id) atlasWithTileFile:(NSString*)tile tileWidth:(int)w tileHeight:(int)h itemsToRender: (int) c;
  63. /** initializes an CCAtlasNode with an Atlas file the width and height of each item and the quantity of items to render*/
  64. -(id) initWithTileFile:(NSString*)tile tileWidth:(int)w tileHeight:(int)h itemsToRender: (int) c;
  65. /** updates the Atlas (indexed vertex array).
  66. * Shall be overriden in subclasses
  67. */
  68. -(void) updateAtlasValues;
  69. @end