Skip to content

Commit

Permalink
fixes issue cocos2d#1314, issue cocos2d#1287 again
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardoquesada committed Feb 21, 2012
1 parent 782fed8 commit e5a51f4
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 33 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ version 2.0-rc0 XX-Feb-2012
. [FIX] GLProgram: report error correctly if vertex shader has compile issues
. [FIX] GLView: Fixed memory leak while dispatching events (Mac only)
. [FIX] GLView: MSAA support is working (issue #1315)
. [FIX] Node: flip, visible are bool (and not BOOL) to prevent signed issues (issue #1314, issue #1287)
. [FIX] Node: flip, visible are no longer bitfields to prevent signed issues (issue #1314, issue #1287)
. [FIX] Particles: Fixed memory leak in fillWithEmptyQuadsFromIndex
. [FIX] Progress: works with rotated sprite frames (issue #1303)
. [FIX] Sprite: adding family of sprites to a batchnode works as expected (issue #1217)
Expand Down
21 changes: 10 additions & 11 deletions cocos2d/CCNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,23 +165,22 @@ enum {
CCActionManager *actionManager_;

// Is running
bool isRunning_:1;
BOOL isRunning_;

// To reduce memory, place BOOLs that are not properties here:
bool isTransformDirty_:1;
bool isInverseDirty_:1;
BOOL isTransformDirty_;
BOOL isInverseDirty_;

// is visible
bool visible_:1;
BOOL visible_;
// If YES the transformtions will be relative to (-transform.x, -transform.y).
// Sprites, Labels and any other "small" object uses it.
// Scenes, Layers and other "whole screen" object don't use it.
bool isRelativeAnchorPoint_:1;
BOOL isRelativeAnchorPoint_;

bool isReorderChildDirty_:1;
BOOL isReorderChildDirty_;

// userData is going to be retained.
bool retainUserData_:1;
BOOL retainUserData_;
}

/** The z order of the node relative to its "siblings": children of the same parent */
Expand Down Expand Up @@ -226,7 +225,7 @@ enum {
/** A CCGrid object that is used when applying effects */
@property(nonatomic,readwrite,retain) CCGridBase* grid;
/** Whether of not the node is visible. Default is YES */
@property(nonatomic,readwrite,assign) bool visible;
@property(nonatomic,readwrite,assign) BOOL visible;
/** anchorPoint is the point around which all transformations and positioning manipulations take place.
It's like a pin in the node where it is "attached" to its parent.
The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner.
Expand All @@ -248,14 +247,14 @@ enum {
@property (nonatomic,readwrite) CGSize contentSize;

/** whether or not the node is running */
@property(nonatomic,readonly) bool isRunning;
@property(nonatomic,readonly) BOOL isRunning;
/** A weak reference to the parent */
@property(nonatomic,readwrite,assign) CCNode* parent;
/** If YES the transformtions will be relative to its anchor point.
* Sprites, Labels and any other sizeble object use it have it enabled by default.
* Scenes, Layers and other "whole screen" object don't use it, have it disabled by default.
*/
@property(nonatomic,readwrite,assign) bool isRelativeAnchorPoint;
@property(nonatomic,readwrite,assign) BOOL isRelativeAnchorPoint;
/** A tag used to identify the node easily */
@property(nonatomic,readwrite,assign) NSInteger tag;
/** A custom user data pointer */
Expand Down
2 changes: 1 addition & 1 deletion cocos2d/CCNode.m
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ -(void) setPosition: (CGPoint)newPosition
isTransformDirty_ = isInverseDirty_ = YES;
}

-(void) setIsRelativeAnchorPoint: (bool)newValue
-(void) setIsRelativeAnchorPoint: (BOOL)newValue
{
isRelativeAnchorPoint_ = newValue;
isTransformDirty_ = isInverseDirty_ = YES;
Expand Down
24 changes: 12 additions & 12 deletions cocos2d/CCSprite.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@
NSUInteger atlasIndex_; // Absolute (real) Index on the batch node
CCSpriteBatchNode *batchNode_; // Used batch node (weak reference)
CGAffineTransform transformToBatch_; //
bool dirty_:1; // Sprite needs to be updated
bool recursiveDirty_:1; // Subchildren needs to be updated
bool hasChildren_:1; // optimization to check if it contain children
bool shouldBeHidden_:1; // should not be drawn because one of the ancestors is not visible
BOOL dirty_; // Sprite needs to be updated
BOOL recursiveDirty_; // Subchildren needs to be updated
BOOL hasChildren_; // optimization to check if it contain children
BOOL shouldBeHidden_; // should not be drawn because one of the ancestors is not visible

//
// Data used when the sprite is self-rendered
Expand All @@ -89,7 +89,7 @@
CGRect rect_;

// texture
bool rectRotated_:1;
BOOL rectRotated_;

// Offset Position (used by Zwoptex)
CGPoint offsetPosition_;
Expand All @@ -102,39 +102,39 @@
GLubyte opacity_;
ccColor3B color_;
ccColor3B colorUnmodified_;
bool opacityModifyRGB_:1;
BOOL opacityModifyRGB_;

// image is flipped
bool flipX_:1;
bool flipY_:1;
BOOL flipX_:1;
BOOL flipY_:1;
}

/** whether or not the Sprite needs to be updated in the Atlas */
@property (nonatomic,readwrite) bool dirty;
@property (nonatomic,readwrite) BOOL dirty;
/** the quad (tex coords, vertex coords and color) information */
@property (nonatomic,readonly) ccV3F_C4B_T2F_Quad quad;
/** The index used on the TextureAtlas. Don't modify this value unless you know what you are doing */
@property (nonatomic,readwrite) NSUInteger atlasIndex;
/** returns the texture rect of the CCSprite in points */
@property (nonatomic,readonly) CGRect textureRect;
/** returns whether or not the texture rectangle is rotated */
@property (nonatomic,readonly) bool textureRectRotated;
@property (nonatomic,readonly) BOOL textureRectRotated;
/** whether or not the sprite is flipped horizontally.
It only flips the texture of the sprite, and not the texture of the sprite's children.
Also, flipping the texture doesn't alter the anchorPoint.
If you want to flip the anchorPoint too, and/or to flip the children too use:
sprite.scaleX *= -1;
*/
@property (nonatomic,readwrite) bool flipX;
@property (nonatomic,readwrite) BOOL flipX;
/** whether or not the sprite is flipped vertically.
It only flips the texture of the sprite, and not the texture of the sprite's children.
Also, flipping the texture doesn't alter the anchorPoint.
If you want to flip the anchorPoint too, and/or to flip the children too use:
sprite.scaleY *= -1;
*/
@property (nonatomic,readwrite) bool flipY;
@property (nonatomic,readwrite) BOOL flipY;
/** opacity: conforms to CCRGBAProtocol protocol */
@property (nonatomic,readwrite) GLubyte opacity;
/** RGB colors: conforms to CCRGBAProtocol protocol */
Expand Down
12 changes: 6 additions & 6 deletions cocos2d/CCSprite.m
Original file line number Diff line number Diff line change
Expand Up @@ -746,38 +746,38 @@ -(void)setAnchorPoint:(CGPoint)anchor
SET_DIRTY_RECURSIVELY();
}

-(void)setIsRelativeAnchorPoint:(bool)relative
-(void)setIsRelativeAnchorPoint:(BOOL)relative
{
NSAssert( ! batchNode_, @"relativeTransformAnchor is invalid in CCSprite");
[super setIsRelativeAnchorPoint:relative];
}

-(void)setVisible:(bool)v
-(void)setVisible:(BOOL)v
{
[super setVisible:v];
SET_DIRTY_RECURSIVELY();
}

-(void)setFlipX:(bool)b
-(void)setFlipX:(BOOL)b
{
if( flipX_ != b ) {
flipX_ = b;
[self setTextureRect:rect_ rotated:rectRotated_ untrimmedSize:contentSize_];
}
}
-(bool) flipX
-(BOOL) flipX
{
return flipX_;
}

-(void) setFlipY:(bool)b
-(void) setFlipY:(BOOL)b
{
if( flipY_ != b ) {
flipY_ = b;
[self setTextureRect:rect_ rotated:rectRotated_ untrimmedSize:contentSize_];
}
}
-(bool) flipY
-(BOOL) flipY
{
return flipY_;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Box2dTest.mm
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ -(void) setPhysicsBody:(b2Body *)body
// this method will only get called if the sprite is batched.
// return YES if the physics values (angles, position ) changed
// If you return NO, then nodeToParentTransform won't be called.
-(bool) dirty
-(BOOL) dirty
{
return YES;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/ChipmunkAccelTouchTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ -(void) setPhysicsBody:(cpBody *)body
// this method will only get called if the sprite is batched.
// return YES if the physics values (angles, position ) changed
// If you return NO, then nodeToParentTransform won't be called.
-(bool) dirty
-(BOOL) dirty
{
return YES;
}
Expand Down

0 comments on commit e5a51f4

Please sign in to comment.