/cocos2d/CCAtlasNode.h

http://github.com/cocos2d/cocos2d-iphone · C Header · 98 lines · 26 code · 19 blank · 53 comment · 0 complexity · af73a89303459f157b93f3aa8fcd4d0d MD5 · raw file

  1. /*
  2. * cocos2d for iPhone: http://www.cocos2d-iphone.org
  3. *
  4. * Copyright (c) 2008-2010 Ricardo Quesada
  5. * Copyright (c) 2011 Zynga Inc.
  6. *
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a copy
  9. * of this software and associated documentation files (the "Software"), to deal
  10. * in the Software without restriction, including without limitation the rights
  11. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. * copies of the Software, and to permit persons to whom the Software is
  13. * furnished to do so, subject to the following conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be included in
  16. * all copies or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24. * THE SOFTWARE.
  25. */
  26. #import "CCTextureAtlas.h"
  27. #import "CCNode.h"
  28. #import "CCProtocols.h"
  29. @class CCTexture2D;
  30. /** CCAtlasNode is a subclass of CCNode that implements the CCRGBAProtocol and
  31. CCTextureProtocol protocol
  32. It knows how to render a TextureAtlas object.
  33. If you are going to render a TextureAtlas consider sub-classing CCAtlasNode (or a subclass of CCAtlasNode)
  34. All features from CCNode are valid, plus the following features:
  35. - opacity and RGB colors
  36. */
  37. @interface CCAtlasNode : CCNodeRGBA <CCTextureProtocol>
  38. {
  39. // texture atlas
  40. CCTextureAtlas *_textureAtlas;
  41. // chars per row
  42. NSUInteger _itemsPerRow;
  43. // chars per column
  44. NSUInteger _itemsPerColumn;
  45. // width of each char
  46. NSUInteger _itemWidth;
  47. // height of each char
  48. NSUInteger _itemHeight;
  49. // quads to draw
  50. NSUInteger _quadsToDraw;
  51. // blend function
  52. ccBlendFunc _blendFunc;
  53. // texture RGBA.
  54. ccColor3B _colorUnmodified;
  55. BOOL _opacityModifyRGB;
  56. // color uniform
  57. GLint _uniformColor;
  58. }
  59. /** conforms to CCTextureProtocol protocol */
  60. @property (nonatomic,readwrite,strong) CCTextureAtlas *textureAtlas;
  61. /** conforms to CCTextureProtocol protocol */
  62. @property (nonatomic,readwrite) ccBlendFunc blendFunc;
  63. /** conforms to CCRGBAProtocol protocol */
  64. @property (nonatomic,readwrite) ccColor3B color;
  65. /** how many quads to draw */
  66. @property (nonatomic,readwrite) NSUInteger quadsToDraw;
  67. /** creates a CCAtlasNode with an Atlas file the width and height of each item measured in points and the quantity of items to render*/
  68. +(id) atlasWithTileFile:(NSString*)tile tileWidth:(NSUInteger)w tileHeight:(NSUInteger)h itemsToRender: (NSUInteger) c;
  69. /** initializes an CCAtlasNode with an Atlas file the width and height of each item measured in points and the quantity of items to render*/
  70. -(id) initWithTileFile:(NSString*)tile tileWidth:(NSUInteger)w tileHeight:(NSUInteger)h itemsToRender: (NSUInteger) c;
  71. /** initializes an CCAtlasNode with a texture the width and height of each item measured in points and the quantity of items to render*/
  72. -(id) initWithTexture:(CCTexture2D*)texture tileWidth:(NSUInteger)w tileHeight:(NSUInteger)h itemsToRender: (NSUInteger) c;
  73. /** updates the Atlas (indexed vertex array).
  74. * Shall be overridden in subclasses
  75. */
  76. -(void) updateAtlasValues;
  77. @end