Exemple #1
0
  @Override
  public CCNode addChild(CCNode child, int z, int aTag) {
    super.addChild(child, z, aTag);

    if (child instanceof CCSprite && usesSpriteSheet_) {
      CCSprite sprite = (CCSprite) child;
      int index = spriteSheet_.atlasIndex(sprite, z);
      spriteSheet_.insertChild(sprite, index);
    }

    hasChildren_ = true;

    return this;
  }
Exemple #2
0
  public void removeChild(CCNode node, boolean doCleanup) {
    if (usesSpriteSheet_) {
      CCSprite sprite = (CCSprite) node;
      spriteSheet_.removeSpriteFromAtlas(sprite);
    }

    super.removeChild(node, doCleanup);

    hasChildren_ = (children_.size() > 0);
  }
Exemple #3
0
  public void removeAllChildren(boolean doCleanup) {
    if (usesSpriteSheet_) {
      for (CCNode child : children_) {
        CCSprite sprite = (CCSprite) child;
        spriteSheet_.removeSpriteFromAtlas(sprite);
      }
    }

    super.removeAllChildren(doCleanup);
    hasChildren_ = false;
  }
Exemple #4
0
 /**
  * tell the sprite to use sprite sheet render.
  *
  * @since v0.99.0
  */
 public void useSpriteSheetRender(CCSpriteSheet spriteSheet) {
   usesSpriteSheet_ = true;
   textureAtlas_ = spriteSheet.getTextureAtlas(); // weak ref
   spriteSheet_ = spriteSheet; // weak ref
 }
Exemple #5
0
 /** Initializes an sprite with an CCSpriteSheet and a rect */
 public CCSprite(CCSpriteSheet spritesheet, CGRect rect) {
   init(spritesheet.getTexture(), rect);
   useSpriteSheetRender(spritesheet);
 }