Beispiel #1
0
  protected void init(CCSpriteFrame spriteFrame) {
    assert spriteFrame != null : "Invalid spriteFrame for sprite";

    rectRotated_ = spriteFrame.rotated_;
    init(spriteFrame.getTexture(), spriteFrame.getRect());
    setDisplayFrame(spriteFrame);
  }
Beispiel #2
0
 /** Initializes an sprite with a texture and a rect. The offset will be (0,0). */
 protected void init(CCTexture2D texture, CGRect rect) {
   assert texture != null : "Invalid texture for sprite";
   // IMPORTANT: [self init] and not [super init];
   init();
   setTexture(texture);
   setTextureRect(rect);
 }
Beispiel #3
0
  /** Initializes an sprite with an image filepath, and a rect. The offset will be (0,0). */
  public CCSprite(String filepath, CGRect rect) {
    assert filepath != null : "Invalid filename for sprite";

    CCTexture2D texture = CCTextureCache.sharedTextureCache().addImage(filepath);
    if (texture != null) {
      init(texture, rect);
    }
  }
Beispiel #4
0
  /**
   * Initializes an sprite with a CGImageRef and a key The key is used by the CCTextureCache to know
   * if a texture was already created with this CGImage. For example, a valid key
   * is: @"sprite_frame_01". If key is nil, then a new texture will be created each time by the
   * CCTextureCache.
   *
   * @since v0.99.0
   */
  public CCSprite(Bitmap image, String key) {
    assert image != null : "Invalid CGImageRef for sprite";

    // XXX: possible bug. See issue #349. New API should be added
    CCTexture2D texture = CCTextureCache.sharedTextureCache().addImage(image, key);

    CGSize size = texture.getContentSize();
    CGRect rect = CGRect.make(0, 0, size.width, size.height);

    init(texture, rect);
  }
Beispiel #5
0
  /**
   * Initializes an sprite with an image filepath. The rect used will be the size of the image. The
   * offset will be (0,0).
   */
  public CCSprite(String filepath) {
    assert filepath != null : "Invalid filename for sprite";

    CCTexture2D texture = CCTextureCache.sharedTextureCache().addImage(filepath);
    if (texture != null) {
      CGRect rect = CGRect.make(0, 0, 0, 0);
      rect.size = texture.getContentSize();
      init(texture, rect);
    } else {
      ccMacros.CCLOGERROR("CCSprite", "Unable to load texture from file: " + filepath);
    }
  }
Beispiel #6
0
 /** Initializes an sprite with an CCSpriteSheet and a rect */
 public CCSprite(CCSpriteSheet spritesheet, CGRect rect) {
   init(spritesheet.getTexture(), rect);
   useSpriteSheetRender(spritesheet);
 }
Beispiel #7
0
 public CCSprite() {
   init();
 }
Beispiel #8
0
 /**
  * Initializes an sprite with an sprite frame name. An CCSpriteFrame will be fetched from the
  * CCSpriteFrameCache by name. If the CCSpriteFrame doesn't exist it will raise an exception.
  *
  * @since v0.9
  */
 public CCSprite(String spriteFrameName, boolean isFrame) {
   assert spriteFrameName != null : "Invalid spriteFrameName for sprite";
   CCSpriteFrame frame =
       CCSpriteFrameCache.sharedSpriteFrameCache().getSpriteFrame(spriteFrameName);
   init(frame);
 }
Beispiel #9
0
 /** Initializes an sprite with an sprite frame. */
 public CCSprite(CCSpriteFrame spriteFrame) {
   init(spriteFrame);
 }
Beispiel #10
0
 public CCSprite(CCTexture2D texture, CGRect rect) {
   init(texture, rect);
 }
Beispiel #11
0
 /**
  * Initializes an sprite with a texture. The rect used will be the size of the texture. The offset
  * will be (0,0).
  */
 public CCSprite(CCTexture2D texture) {
   CGSize size = texture.getContentSize();
   CGRect rect = CGRect.make(0, 0, size.width, size.height);
   init(texture, rect);
 }