Dieses Dokuwiki verwendet ein von Anymorphic Webdesign erstelltes Thema.

cocos2d for iPhone v0.9.0-beta2 Release Notes

Download

You can download cocos2d for iPhone v0.9.0-beta2 from here:

http://cocos2d-iphone.googlecode.com/files/cocos2d-iphone-0.9.0-beta2.tar.gz

cocos2d v0.9.0-beta2 is SVN revision 1678

Documentation

You can find the v0.9.0-beta2 documentation here:

Performance

To understand how fast cocos2d v0.9.0-beta2 is, please see the performance tests

DISCLAIMER: Beta2 performance tests are not ready yet, but preliminary tests tell that v0.9-beta2 is as fast as v0.9-beta.

New features

CC Namespace

Issue #520

v0.9 classes have the CC prefix. This prefix was added in order to prevent collision with other possible libraries or user code. So, it is safe to assume that:

  • Classes that start with CC belong to cocos2d.
  • Classes that don't start with CC don't belong to cocos2d

Example:

// v0.8.x classes
Sprite *sprite = [Sprite sprite....];
Director *director = [Director sharedDirector];
Scene *scene = [Scene ...];
Layer *layer = [Layer ...];
 
// 0.9.0 classes
CCSprite *sprite = [CCSprite sprite....];
CCDirector *director = [CCDirector sharedDirector];
CCScene *scene = [CCScene ...];
CCLayer *layer = [CCLayer ...];

There are some exceptions:

  • The CocosNode class was renamed to CCNode
  • The TextureMgr class was renamed to CCTextureCache

For further info, please see: Migrating to v0.9

Sprite / AtlasSprite merge

Issue #620

In v0.9 AtlasSprite and Sprite were merged in one single class: CCSprite.

New classes:

  • SpriteCCSprite
  • AtlasSpriteCCSprite
  • AtlasSpriteFrameCCSpriteFrame
  • SpriteFrameCCSpriteFrame
  • AnimationCCAnimation
  • AtlasAnimationCCAnimation
  • AtlasSpriteManagerCCSpriteSheet ← NEW NAME

Example:

// v0.8 code: Atlas Sprites
AtlasSpriteManager *mgr = [AtlasSpriteManager spriteManager...];
AtlasSprite *sprite = [mgr createSpriteWith...];
[mgr addChild:sprite];
 
// v0.9 code
CCSpriteSheet *sheet = [CCSpriteSheet spriteSheet...];
CCSprite *sprite = [sheet createSpriteWith...];
[sheet addChild:sprite];
 
// v0.8 code: Sprites
Sprite *sprite = [Sprite spriteWith...];
[self addChild:sprite];
 
// v0.9 code
CCSprite *sprite = [CCSprite spriteWith...];
[self addChild:sprite];

As you can see, CCSprite can be used as a normal sprite or as a fast sprite when it is parented to an CCSpriteSheet.

But CCSpriteSheet has some limitations:

  • Only accepts CCSprites as children
  • CCSprites must have the same texture id as the CCSpriteSheet

CCSpriteFrameCache / Zwoptex support

The animation code in v0.9 was also merged:

  • Animation → CCAnimation
  • AtlasAnimation → CCAnimation

Migrating Animation to CCAnimation

v0.8 code:

Animation *sapusAnim = [Animation animationWithName:@"select" delay:0.3f images:@"SapusSelected1.png", @"SapusSelected2.png", @"SapusSelected1.png", @"SapusUnselected.png", nil];

v0.9 code:

CCAnimation *sapusAnim = [CCAnimation animationWithName:@"select" delay:0.3f];
[sapusAnim addFrameWithFilename:@"SapusSelected1.png"];
[sapusAnim addFrameWithFilename:@"SapusSelected2.png"];
[sapusAnim addFrameWithFilename:@"SapusSelected1.png"];
[sapusAnim addFrameWithFilename:@"SapusUnselected.png"];

Migrating AtlasAnimation to CCAnimation

v0.8 code:

AtlasAnimation *animFly = [AtlasAnimation animationWithName:@"fly" delay:0.2f];
[animFly addFrameWithRect: CGRectMake(64*0, 64*0, 64, 64)];
[animFly addFrameWithRect: CGRectMake(64*1, 64*0, 64, 64)];
[animFly addFrameWithRect: CGRectMake(64*2, 64*0, 64, 64)];

v0.9 code:

CCAnimation *animFly = [CCAnimation animationWithName:@"fly" delay:0.2f];
[animFly addFrameWithTexture:spriteSheet.texture rect:CGRectMake(64*0, 64*0, 64, 64)];
[animFly addFrameWithTexture:spriteSheet.texture rect:CGRectMake(64*1, 64*0, 64, 64)];
[animFly addFrameWithTexture:spriteSheet.texture rect:CGRectMake(64*2, 64*0, 64, 64)];

Taking advantage of CCSpriteFrameCache

One of the benefits of v0.9 is the CCSpriteFrameCache class, since it lets you write animation code more easily.

CCSpriteFrameCache is an sprite frame cache. Basically you can add frames to this cache, and you can get them by name. You can easily create an animation using the frame cache.

CCSpriteFrameCache supports the Zwoptex format. The zwoptex format is easy to parse and use. In case you decide not to use use, you can also add sprite frames to the cache by adding them manually, or by adding them with an NSDictionary.

eg:

// loads the sprite frames from a Zwoptex generated file
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"animations/grossini.plist"];
 
NSMutableArray *animFrames = [NSMutableArray array];
for(int i = 0; i < 14; i++) {		
	CCSpriteFrame *frame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"grossini_dance_%02d.png",(i+1)]];
	[animFrames addObject:frame];
}
 
CCAnimation *animation = [CCAnimation animationWithName:@"dance" delay:0.2f frames:animFrames];

For further info, please see: Migrating to v0.9

CCSpriteSheet supports children

Issues #346, #665

// Create an SpriteSheet
CCSpriteSheet *sheet = [CCSpriteSheet spriteSheetWithFile:@"animations/grossini.png" capacity:50];
 
// Add sprite sheet to parent
[self addChild:sheet];
 
// Load sprite frames	
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"animations/grossini.plist"];
 
 
CCSprite *sprite1 = [CCSprite spriteWithSpriteFrameName:@"grossini_dance_01.png"];
[sprite1 setPosition:ccp( s.width/3, s.height/2)];
 
CCSprite *sprite2 = [CCSprite spriteWithFrameFrameName:@"grossini_dance_02.png"];
[sprite2 setPosition:ccp(50,50)];
 
CCSprite *sprite3 = [CCSprite spriteWithSpriteFrameName:@"grossini_dance_03.png"];
[sprite3 setPosition:ccp(-50,-50)];
 
[sheet addChild:sprite1];
 
// NEW NEW NEW
// sprite1 supports children
[sprite1 addChild:sprite2];
[sprite1 addChild:sprite3];

Full example:

CCSpriteSheet supports "honor transform" flag

Issue #643

Suppose that you want to create a health bar on top of your sprite. The easiest way to do it is by adding the health bar as a child of your sprite. This works as expected expect if you sprite rotates, since the health bar will rotate too. To prevent this behavior the CCSprite object has a new property: honorParentTransform.

By default the child (in our example, the “health bar”) will rotate, translate and scale relative to it's parent. But we can override this behavior by:

// default value
healthBar.honorParentTransform = CC_HONOR_PARENT_TRANSFORM_ALL;
 
// ignores parent rotation
healthBar.honorParentTransform &= ~CC_HONOR_PARENT_TRANSFORM_ROTATE;
 
// ignores parent scale
healthBar.honorParentTransform &= ~CC_HONOR_PARENT_TRANSFORM_SCALE;
 
// ignores parent scale
healthBar.honorParentTransform &= ~CC_HONOR_PARENT_TRANSFORM_TRANSLATE;

Full example:

Improved features

Actions

Animate

Issue #627

The CCAnimate action now supports reverse. Example:

id action = [CCAnimate actionWithAnimation: animation restoreOriginalFrame:NO];
id action_back = [action reverse];
 
[sprite runAction: [CCSequence actions: action, action_back, nil]];

FlipX / FlipY

Since part of issue #620 was rollbacked, these 2 Instant Actions where added.

Example:

CCSequence *seq = [CCSequence actions: animate,
				   [CCFlipX actionWithFlipX:YES],
				   [[animate copy] autorelease],
				   [CCFlipX actionWithFlipX:NO],
				   nil];
 
[sprite runAction:[CCRepeatForever actionWithAction: seq ]];

Repeat / RepeatForever

Issue #390

CCRepeat and CCRepeatForever repeat the action without jerking. The repetitions are smooth now.

RotateTo

Issue #705

CCRotateTo works as expected when it is part of a CCRepeat action.

BitmapFontAtlas

Issue #612 Issue #610

  • CCBitmapFontAtlas works with subdirectories.
  • setString doesn't override color

Example:

// subdirectory
CCBitmapFontAtlas *label1 = [CCBitmapFontAtlas bitmapFontAtlasWithString:@"Test" fntFile:@"fonts/bitmapFontTest2.fnt"];
[self addChild:label1];
 
// color
[label1 setColor:ccRED];
[label1 setString:@"This is a red string"];

Box2d

Issue #494

Box2d was updated to r31. Since r31 you should specify body type. Example:

b2BodyDef bd;
bd.type = b2DynamicBody; // default type is static body

Chipmunk

Issue #664

  • Chipmunk was updated to v5.0.
  • The Chipmunk test best was updated to use cocos2d
  • The ChipmunkAccelTouch demo was updated to support chipmunk v5.0

ColorLayer

Issue #597

  • CCColorLayer supports the CCBlendProtocol. You can create “negative” images with it.

Full example:

CocosDenshion

Issues #593 ,#595

  • Added support for detecting ringer/mute switch state
  • Doesn't crash when file has no extension

Node / Scheduler

Issue #630

CCNode supports scheduling methods with the optional repeat argument.

Example:

-(id) init
{
	if( !( self=[super init]) )
		return nil;
 
	CCSprite *sp1 = [CCSprite spriteWithFile:@"grossinis_sister1.png"];
	CCSprite *sp2 = [CCSprite spriteWithFile:@"grossinis_sister2.png"];
 
	sp1.position = ccp(100,160);
	sp2.position = ccp(380,160);
 
	[self addChild:sp1 z:0 tag:2];
	[self addChild:sp2 z:0 tag:3];
 
	[self schedule:@selector(doRotate:) interval:2.0f repeat:4];  // sister1 should rotate 4 times only
	[self schedule:@selector(doRotate2:) interval:2.0f];		// sister2 should keep rotating
 
	return self;
}

Texture2D

Issue #632 Issue #697

  • It's possible to generate mipmap textures in runtime.
  • Simulator and Device display the same image, no matter if the have alpha premultiplied or not.
// mipmaps
CCTexture2D *texture0 = [[CCTextureCache sharedTextureCache] addImage:@"grossini_dance_atlas.png"];
// generate mipmap textures
[texture0 generateMipmap];
 
// update the tex parameters so MIPMAP_LINEAR is used
ccTexParams texParams = { GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE };     
[texture0 setTexParameters:&texParams];

Full example:

TextureAtlas

Issue #581

The CCTextureAtlas object (used by CCSpriteSheet) uses by default VBO instead of vertex array list.

TMXTiledMaps

Issue #539 Issue #636

  • CCTMXTiledMap works with subdirectories.
  • Added support for object_group
  • Works as fast as in v0.8.2
  • Fixed memory corruption when removing children

Example:

// subdirectory example
CCTMXTiledMap *map = [CCTMXTiledMap tiledMapWithTMXFile:@"TileMaps/orthogonal-test4.tmx"];
[self addChild:map z:0 tag:kTagTileMap];

Transition

Issue #646

  • Added CCCrossFadeTransition. It fades in the incoming scene while the outgoing scene fades out.

Full example:

Compatibility Issues

Please see the Migrating to v0.9 wiki page.

Deprecated /Removed API

Deprecated classes/methods

All deprecated classes/methods in v0.8.x were removed from v0.9

Removed MenuItemAtlasSprite

Issue #620

MenuItemAtlasSprite was removed because:

  • In v0.9 CCSprites supports rects
  • MenuItemAtlasSprite was a hack. You needed to add the items in 2 different places and it wasn't obvious at all
  • Usually you don't need a lot of performance to display a menu. If you have 20 items, the performance between MenuItemAtlasSprite and MenuItemSprite should be more or less equal

Added / Removed Files

Steps to use the v0.9 cocos2d files:

  • Open your game XCode project
  • From XCode remove the (v0.8) cocos2d folder: delete the references also moving them to the trash folder
  • download cocos2d v0.9 (latest v0.9 version)
  • copy the v0.9 cocos2d directory to your game directory
  • From XCode, include the recently copied cocos2d directory

Changes from v0.8.2

Full changelog: CHANGELOG

Changes in v0.9.0-beta2

version 0.9.0-beta - 11-Jan-2010

  • Actions: added 2 new instant actions: FlipX and FlipY (counter-rollback of part issue #620)
  • Actions: uses FLT_EPSILON constant (issue #701)
  • Actions: prevent jerk in Repeat and RepeatForEver (issue #390)
  • Actions: RotateTo can be repeated without losing information (issue #705)
  • BitmapFontAtlas: doesn't override color when using setString (issue #610)
  • Chipmunk: removed compiler warning on chipmunk demo (issue #680)
  • CocosLive: added sanity checks on demo (issue #681)
  • Director: removed compile warning on DisplayLink director (issue #682)
  • Particles: prevent possible memory corruption when autoRemove is ON (issue #703)
  • Scheduler: Supports repeat-number-of-times in scheduled selectors (issue #630)
  • Sprite: anchor + offset + scale works (issue #671)
  • Sprite: can create subclasses with an SpriteFrameName (issue #XXX)
  • Sprite: flip works as scale * -1 (issue #690)
  • Sprite: easier to subclass. [self init] is called (issue #485)
  • Sprite: isFrameDisplayed works OK with offsets (issue #707)
  • SpriteFrame: removed support for flipX and flipY (rollback of a part issue #620)
  • SpriteFrameCache: If originalSize is not present, display warning (issue #670)
  • SpriteSheet: adding grand-children doesn't crash (issue #676)
  • SpriteSheet: child and children works OK with negative scales (issue #677)
  • SpriteSheet: It is easier to subclass (issue #397)
  • Templates: uses rfc1034identifier (issue #685)
  • Texture2D: simulator treats pre-multiplied alpha images correctly (issue #697)
  • TextureCache: doesn't crash when file not found. log error insted (issue #695)
  • TMXTiledMap: added support for object and objectgroup (issue #636)
  • TMXTiledMap: TMXLayer and TMXObjectGroup on it's own files (part of issue #636)
  • TMXTiledMap: doesn't generate descendants when not necessary (works as fast as in v0.8.2)
  • TMXTiledMap: removeChild works without corrupting the tilemap (issue #XXX)

Changes in v0.9.0-beta

version 0.9.0-beta - 14-Dic-2009

  • ActionManager: fixed leak (issue #635)
  • Actions: using [self class]. Easier to subclass (issue #655)
  • Box2d: updated to r31 (pre 2.1.0) (issue #494)
  • Chipmunk: updated to v5.0 (issue #664)
  • CocosDenshion: support for detecting ringer/mute switch state (issue #593)
  • CocosDenshion: doesn't crash when file has no extension (issue #595)
  • ColorLayer: supports Blend Protocol (issue #597)
  • Node: vertexZ is translated just once (issue #641)
  • Director: call schedulers before glClear in mainLoop (part of issue #533)
  • Director: “global” NSBundle to facilitate the integration of more than 1 game (issue #654)
  • Particles: code easier to mantain, same performance
  • Particles: small performance improvement (issue #661)
  • SpriteSheet: supports any level of sub-children (issue #346, issue #665)
  • Sprite: supports “honor parent transform” (issue #643)
  • Sprite: displayFrame renamed to displayedFrame (issue #XXX)
  • Sprite: fixed zwoptex offset & anchorPoint (issue #653)
  • Sprite: setDisplayFrame works OK with different texture sizes (issue #666)
  • Templates: using SDK 3.0 as base SDK
  • Textures: supports mipmap generation (issue #632)
  • Texture Atlas: uses VBO instead of vertex array list (issue #581)
  • TextureCache: don't use autorelease pool to load images (issue #XXX)
  • Tiles: TMX maps supports sub-directories (issue #539)
  • Transition: added CrossFadeTransition (issue #646)

Changes in v0.9.0-alpha

version 0.9.0-alpha - 18-Nov-2009

  • All: using CC namespace (issue #520)
  • All: prevents warnings with Static Analizer (issue #613)
  • All: cocos protocols renamed to avoid confusion (part of issue #520)
  • All: Added compatibility with v0.8 (part of issue #520)
  • Animation: supports duration and reverse (issue #627)
  • Tests: Performance Tests re-integrated to main XCode project (issue #XXX)
  • BitmapFontAtlas: works with subdirectories (issue #612)
  • Box2d: updated to r26 (pre 2.1.0) (issue #494)
  • CocosLive: Uses CL namespace (part of issue #520)
  • CocosLive: Uses ASCII encoder (issue #617)
  • Sprite: Sprite and AtlasSprite merged in just one class (issue #620)
  • Sprite: AtlasSpriteManager renamed to SpriteSheet (issue #620)
  • Sprite: Sprite Frames and animations supports flipx / flipy (issue #620)
  • SpriteFrameCache: added an easier way to create animations and sprites (issue #620)
  • Templates: updated (part of issue #520 and issue #620)
  • Templates: includes cocos2d and CocosDenshion licences files
  • TextureMgr: renamed to TextureCache (part of issue #620)
  • XCode: textures files in 1 xcode group (Texture2d, PVRTexture, TextureAltas, TextureCache)
release_notes/0_9_0_beta2.txt · Last modified: 2010/01/11 15:57 by admin
Trace: faq 0_8_2 0_8_2_rc1 0_9_0_beta 0_9_0_beta2
Dieses Dokuwiki verwendet ein von Anymorphic Webdesign erstelltes Thema.
CC Attribution-Noncommercial-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0