Skip to content

Commit

Permalink
[Cocos2d-JS]Update 3.0beta upgrade guide
Browse files Browse the repository at this point in the history
  • Loading branch information
pandamicro committed May 27, 2014
1 parent 278e518 commit 27329fd
Show file tree
Hide file tree
Showing 2 changed files with 148 additions and 104 deletions.
130 changes: 76 additions & 54 deletions manual/framework/html5/release-notes/v3.0a/upgrade-guide/en.md
Original file line number Diff line number Diff line change
Expand Up @@ -374,23 +374,45 @@ if (cc.sys.isNative) {
* **10.3** cc.AssetsManager
cc.AssetsManager is a class serves for managing and using remote resources on your server. It can also manage versions of resources and update them to most recent versions. Detailed APIs are listed below:
cc.AssetsManager is a class serves for managing and using remote resources on your server. It can also manage versions of resources and update them to most recent versions. Usage of cc.AssetsManager is showing below:
```
var assetsMgr = cc.AssetsManager.create(packageUrl, versionFileUrl, storagePath, errorCallback, progressCallback, successCallback);
assetsMgr.setStoragePath(storagePath)
assetsMgr.setPackageUrl(packageUrl)
assetsMgr.checkUpdate()
assetsMgr.getStoragePath()
assetsMgr.update()
assetsMgr.setConnectionTimeout(timeout)
assetsMgr.setVersionFileUrl(versionFileUrl)
assetsMgr.getPackageUrl()
assetsMgr.getConnectionTimeout()
assetsMgr.getVersion()
assetsMgr.getVersionFileUrl()
assetsMgr.deleteVersion()
var manager = new cc.AssetsManager(manifestPath, storagePath);
// As the process is asynchronised, you need to retain the assets manager to make sure it won't be released before the process is ended.
manager.retain();
if (!manager.getLocalManifest().isLoaded()) {
cc.log("Fail to update assets, step skipped.");
}
else {
var listener = new cc.EventListenerAssetsManager(manager, function(event) {
switch (event.getEventCode())
{
case cc.EventAssetsManager.UPDATE_PROGRESSION:
var percent = event.getPercent();
cc.log("Download percent : " + percent);
break;
case cc.EventAssetsManager.ERROR_DOWNLOAD_MANIFEST:
case cc.EventAssetsManager.ERROR_PARSE_MANIFEST:
cc.log("Fail to download manifest file, update skipped.");
break;
case cc.EventAssetsManager.ALREADY_UP_TO_DATE:
case cc.EventAssetsManager.UPDATE_FINISHED:
cc.log("Update finished.");
// You need to release the assets manager while you are sure you don't need it any more
manager.release();
break;
case cc.EventAssetsManager.ERROR_UPDATING:
cc.log("Asset update error: " + event.getAssetId() + ", " + event.getMessage());
break;
default:
break;
}
}
}
```
For more details, you can refer to this [documentation](../../../v3.0/assets-manager/en.md).
##11. Other API changements
Expand Down Expand Up @@ -595,7 +617,7 @@ if (cc.sys.isNative) {
```
##12.[New in Beta]Actions API changements
* **12.1 Provide shortcut to create an action**
* **12.1 Provide shortcut to create an action**
We provide a shortcut to create an action, same name as action class name with the first character is lower.
For example:
Expand All @@ -607,49 +629,49 @@ if (cc.sys.isNative) {
```
var action = cc.moveBy(2,cc.p(10,10))
```
* **12.2 Refactor ease actions design**
The ease actions are actually decorative actions, they must be attached with target actions and cann't be used individually. All useful codes of the cc.ActionEase and its subclasses are in update functions, so they don't need to inhert from `cc.ActionInterval`, and could be wrapped into a object that provide an `easing` function to change the delta time.
We added a function `easing` to `cc.ActionInterval`, it can be receive one ore more ease objects.
There is a comparison between old usage and new usage, and the new one is more friendly:
**Old usage:**
```
* **12.2 Refactor ease actions design**
The ease actions are actually decorative actions, they must be attached with target actions and cann't be used individually. All useful codes of the cc.ActionEase and its subclasses are in update functions, so they don't need to inhert from `cc.ActionInterval`, and could be wrapped into a object that provide an `easing` function to change the delta time.
We added a function `easing` to `cc.ActionInterval`, it can be receive one ore more ease objects.
There is a comparison between old usage and new usage, and the new one is more friendly:
**Old usage:**
```
var easeMoveBy = cc.EaseIn.create(cc.MoveBy.create(2, cc.p(100,50)),0.3);
```
**New usage:**
```
**New usage:**
```
var easeMoveBy = cc.moveBy(2,cc.p(100,50)).easing(cc.easeIn(0.3);
```
* **12.3 Refactor cc.Repeat, cc.RepeatForever, cc.Speed design**
The cc.Repeat, cc.RepeatForever, cc.Speed are also decorative actions, so we add some functions `repeat`,`repeatForever`,`speed`,`getSpeed`,`setSpeed` to `cc.ActionInterval`. All these changes allow developers to write complex actions more clearly.
There is a comparison between old usage and new usage:
**Old usage:**
```
* **12.3 Refactor cc.Repeat, cc.RepeatForever, cc.Speed design**
The cc.Repeat, cc.RepeatForever, cc.Speed are also decorative actions, so we add some functions `repeat`,`repeatForever`,`speed`,`getSpeed`,`setSpeed` to `cc.ActionInterval`. All these changes allow developers to write complex actions more clearly.
There is a comparison between old usage and new usage:
**Old usage:**
```
var anAction = cc.Sequence.create(
cc.Speed.create(cc.Repeat.create(cc.EaseIn.create(cc.MoveBy.create(2, cc.p(100,50)),0.3), 5),1.7),
cc.RepeatForever.create(cc.RotateBy.create(2, 30)));
```
**New usage:**
```
var anAction = cc.sequence(
cc.moveBy(2,cc.p(100,50)).easing(cc.easeIn(0.3).repeat(5).speed(1.7),
**New usage:**
```
var anAction = cc.sequence(
cc.moveBy(2,cc.p(100,50)).easing(cc.easeIn(0.3).repeat(5).speed(1.7),
cc.rotateBy(2,30).repeatForever());
```
```
**Note**: All actions changes are backward compatible.
* **12.4 The new design list**
Expand Down Expand Up @@ -681,37 +703,37 @@ var anAction = cc.Sequence.create(
##13.[New in Beta]Changed setText,getText to unified API of SetString, getString
* ccui.Text refactoration :
* ccui.Text :
```
setText --> setString
getStringValue --> getString
```
* ccui.TextAtlas
* ccui.TextAtlas :
```
getStringValue ==> getString
```
* ccui.TextBMFont
* ccui.TextBMFont :
```
setText --> setString
getStringValue --> getString
```
* ccui.TextField
* ccui.TextField :
```
setText --> setString
getStringValue --> getString
```
* cc.EditBox
* cc.EditBox :
```
```
setText --> setString
getText --> getString
```
Expand Down
122 changes: 72 additions & 50 deletions manual/framework/html5/release-notes/v3.0a/upgrade-guide/zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -372,23 +372,45 @@ if (cc.sys.isNative) {
* **10.3** cc.AssetsManager
cc.AssetsManager是用于管理和使用远程服务器资源的类,它也支持简单的版本控制和更新。下面是它的API列表
cc.AssetsManager是用于管理和使用远程服务器资源的类,它也支持简单的版本控制和更新。下面是它的使用方式
```
var assetsMgr = cc.AssetsManager.create(packageUrl, versionFileUrl, storagePath, errorCallback, progressCallback, successCallback);
assetsMgr.setStoragePath(storagePath)
assetsMgr.setPackageUrl(packageUrl)
assetsMgr.checkUpdate()
assetsMgr.getStoragePath()
assetsMgr.update()
assetsMgr.setConnectionTimeout(timeout)
assetsMgr.setVersionFileUrl(versionFileUrl)
assetsMgr.getPackageUrl()
assetsMgr.getConnectionTimeout()
assetsMgr.getVersion()
assetsMgr.getVersionFileUrl()
assetsMgr.deleteVersion()
var manager = new cc.AssetsManager(manifestPath, storagePath);
// As the process is asynchronised, you need to retain the assets manager to make sure it won't be released before the process is ended.
manager.retain();
if (!manager.getLocalManifest().isLoaded()) {
cc.log("Fail to update assets, step skipped.");
}
else {
var listener = new cc.EventListenerAssetsManager(manager, function(event) {
switch (event.getEventCode())
{
case cc.EventAssetsManager.UPDATE_PROGRESSION:
var percent = event.getPercent();
cc.log("Download percent : " + percent);
break;
case cc.EventAssetsManager.ERROR_DOWNLOAD_MANIFEST:
case cc.EventAssetsManager.ERROR_PARSE_MANIFEST:
cc.log("Fail to download manifest file, update skipped.");
break;
case cc.EventAssetsManager.ALREADY_UP_TO_DATE:
case cc.EventAssetsManager.UPDATE_FINISHED:
cc.log("Update finished.");
// You need to release the assets manager while you are sure you don't need it any more
manager.release();
break;
case cc.EventAssetsManager.ERROR_UPDATING:
cc.log("Asset update error: " + event.getAssetId() + ", " + event.getMessage());
break;
default:
break;
}
}
}
```
更多信息请参考[cc.AssetsManager文档](../../../v3.0/assets-manager/zh.md).
##11. 其他API变动
Expand Down Expand Up @@ -592,7 +614,7 @@ if (cc.sys.isNative) {
##12.[Beta新添加]Actions API变动
* **12.1 提供action的短方法创建方式**
* **12.1 提供action的短方法创建方式**
我们还针对action的相关类,增加了更加简单的创建方法,通过类名第一个字母改为小写就能创建出一个新的对象:
比如:
Expand All @@ -604,46 +626,46 @@ if (cc.sys.isNative) {
```
var action = cc.moveBy(2,cc.p(10,10))
```
* **12.2 重新设计ease actions**
所有的ease action其实是修饰性的action, 他们无法脱离目标action独立使用. 其有效部分也只是update函数,所以我们可以添加一个`easing` 到 `cc.ActionInterval`中, 它可以接受不同的ease对象来实现不同的ease动作效果。
新旧使用方法的比较,新的调用方式采用链式的调用更加简单、易用:
**旧的调用方式:**
```
* **12.2 重新设计ease actions**
所有的ease action其实是修饰性的action, 他们无法脱离目标action独立使用. 其有效部分也只是update函数,所以我们可以添加一个`easing` 到 `cc.ActionInterval`中, 它可以接受不同的ease对象来实现不同的ease动作效果。
新旧使用方法的比较,新的调用方式采用链式的调用更加简单、易用:
**旧的调用方式:**
```
var easeMoveBy = cc.EaseIn.create(cc.MoveBy.create(2, cc.p(100,50)),0.3);
```
**新的调用方式:**
```
**新的调用方式:**
```
var easeMoveBy = cc.moveBy(2,cc.p(100,50)).easing(cc.easeIn(0.3);
```
* **12.3 关于 cc.Repeat, cc.RepeatForever, cc.Speed 的新设计**
以下的 cc.Repeat, cc.RepeatForever, cc.Speed 都是修饰性的actions, 所以我们添加对应的函数 `repeat`,`repeatForever`,`speed`,`getSpeed`,`setSpeed` 到 `cc.ActionInterval`中. 通过这邪恶函数,开发者可以将原来复杂的动作以清晰的方式进行表示。All these changes allow developers to write complex actions more clearly.
**旧的调用方式:**
```
* **12.3 关于 cc.Repeat, cc.RepeatForever, cc.Speed 的新设计**
以下的 cc.Repeat, cc.RepeatForever, cc.Speed 都是修饰性的actions, 所以我们添加对应的函数 `repeat`,`repeatForever`,`speed`,`getSpeed`,`setSpeed` 到 `cc.ActionInterval`中. 通过这邪恶函数,开发者可以将原来复杂的动作以清晰的方式进行表示。All these changes allow developers to write complex actions more clearly.
**旧的调用方式:**
```
var anAction = cc.Sequence.create(
cc.Speed.create(cc.Repeat.create(cc.EaseIn.create(cc.MoveBy.create(2, cc.p(100,50)),0.3), 5),1.7),
cc.RepeatForever.create(cc.RotateBy.create(2, 30)));
```
**新的调用方式:**
```
var anAction = cc.sequence(
cc.moveBy(2,cc.p(100,50)).easing(cc.easeIn(0.3).repeat(5).speed(1.7),
**新的调用方式:**
```
var anAction = cc.sequence(
cc.moveBy(2,cc.p(100,50)).easing(cc.easeIn(0.3).repeat(5).speed(1.7),
cc.rotateBy(2,30).repeatForever());
```
```
**注意**: 所有的Actions的旧API都保留,并向前兼容。
* **12.4 新增Actions API列表**
Expand Down Expand Up @@ -675,35 +697,35 @@ var anAction = cc.Sequence.create(
##13.[Beta新变动]修改setText,getText为统一的API SetString, getString
* ccui.Text refactoration :
* ccui.Text :
```
setText --> setString
getStringValue --> getString
```
* ccui.TextAtlas
* ccui.TextAtlas :
```
getStringValue ==> getString
```
* ccui.TextBMFont
* ccui.TextBMFont :
```
setText --> setString
getStringValue --> getString
```
* ccui.TextField
* ccui.TextField :
```
setText --> setString
getStringValue --> getString
```
* cc.EditBox
* cc.EditBox :
```
setText --> setString
Expand Down

0 comments on commit 27329fd

Please sign in to comment.