ZhouWeikuan / cocos2d

cocos2d for android, based on cocos2d-android-0.82, and now ported from cocos2d-iphone 0.99.4. The googlecode address is here: http://code.google.com/p/cocos2d-android-1/ . There are several demos to watch.
610 stars 291 forks source link

CCSprite.setTextureRect Modification #41

Open irwinb opened 12 years ago

irwinb commented 12 years ago

The setTextureRect call should probably be

public void setFlipY(boolean b) {
        if( flipY_ != b ) {
            flipY_ = b; 
            setTextureRect(rect_, contentSize_, rectRotated_);
        }   
    }

instead of

public void setFlipY(boolean b) {
        if( flipY_ != b ) {
            flipY_ = b; 
            setTextureRect(rect_); // uses rect_.size instead of contentSize_
        }   
    }

I noticed this when calling flipY( and flipX for that matter) which then starts the setTextureRect chain. The problem occurs, as I've seen, for frames on sprite sheets whose transparent pixels have been cut out to reduce the space they take.

ZhouWeikuan commented 12 years ago

Checked, cocos2d-iphone updated the implementation of setTextureRect related functions, this change would the right adjust.

2011/10/1 Irwin Billing < reply@reply.github.com>

The setTextureRect method should probably be

public void setTextureRect(CGRect rect, Boolean rotated) {
           setTextureRect(rect, contentSize_, rotated);
   }

instead of

public void setTextureRect(CGRect rect, Boolean rotated) {
           setTextureRect(rect, rect.size, rotated);
   }

I noticed this when calling flipX(true) which then starts the setTextureRect chain. The problem occurs, as I've seen, for frames on sprite sheets whose transparent pixels have been cut out to reduce the space they take.

Reply to this email directly or view it on GitHub: https://github.com/ZhouWeikuan/cocos2d/issues/41

This is Zhou, Weikuan(Ϊ)