Skip to content

Commit 82494e9

Browse files
committed
Merge pull request #1 from cocos2d/master
synchronize original project
2 parents be27f15 + 3707ff2 commit 82494e9

File tree

31 files changed

+323
-298
lines changed

31 files changed

+323
-298
lines changed

AUTHORS.txt

+28-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,34 @@ Core Developers:
1515
Ricardo Quesada
1616

1717

18-
Developers:
19-
18+
Contributors:
19+
Name GithubID Main contribution
20+
21+
Dali Kilani @dadilcool added instruction to read me
22+
23+
Chris @hannon235 added node.js api for box2d
24+
25+
Jason Aeschliman @jaeschliman fix cc.Node setposition
26+
27+
Sun Zhuoshi(Intel) @sunzhuoshi engine loader fix
28+
29+
Alejandro Reyero @KaTXi fix error message
30+
31+
Long Xiang @seanlong resource loader count
32+
33+
Timm Drevensek(Zynga) @timmjd cc.Class fix
34+
add CCScale9Sprite test
35+
36+
Lzzy Chen @czizzy audio engine fix
37+
cleanup comments
38+
39+
Mcscooter @mcscooter tilempapxml fix
40+
41+
Roed @roed mouse rightclick api
42+
43+
Surith Thekkiam(Zynga) @folecr match Cocos2dx api
44+
45+
Robert Boyd @rboyd fix stackable actions
2046

2147

2248
Cocos2d-x and cocos2d-html5 can not grow so fast without the active community.

CHANGELOG.txt

+42-33
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,53 @@
1+
Cocos2d-html5-v2.1.1 @ Jan.22, 2013
2+
* Fixed bugs
3+
* Added mouse button to MouseDispatcher, supports right-click
4+
* Changed preload audio type from "bgm" and "effect" to "sound"
5+
* Added "Sys" class for system capabilities
6+
* Improved cc.BuilderReader to support .ccbi extension auto-completion
7+
* Improved TMXXMLParser to support XML, CSV and zlib compression
8+
* Changed cc.Time.gettimeofdayCocos2d to Date.now which is more javascript friendly.
9+
110
Cocos2d-html5-v2.1.0 @ Dec.4, 2012
2-
* Improved cc.Class and add Release Mode.
3-
* All tests and games can now be run on Cocos2d-html5, Cocos2d-iPhone and Cocos2d-x.
4-
* Added support for google.base.
5-
* Added support for CocosBuilder and Bone Animation.
6-
* Updated API for Javascript Binding.
7-
* Integrated Chipmunk physical engine and chipmunk tests.
8-
* Added physicsDebugNode, physicsSprite, drawNode.
9-
* Built cocos2d-js-tests repo for tests.
10-
* Fixed support for mouse/touch/keyboard.
11-
* Fixed bugs.
12-
* Added WaterMelon with me and CocosDragon games for sample.
13-
* Added Edit Box for input.
11+
* Improved cc.Class and add Release Mode
12+
* All tests and games can now be run on Cocos2d-html5, Cocos2d-iPhone and Cocos2d-x
13+
* Added support for google.base
14+
* Added support for CocosBuilder and Bone Animation
15+
* Updated API for Javascript Binding
16+
* Integrated Chipmunk physical engine and chipmunk tests
17+
* Added physicsDebugNode, physicsSprite, drawNode
18+
* Built cocos2d-js-tests repo for tests
19+
* Fixed support for mouse/touch/keyboard
20+
* Fixed bugs
21+
* Added WaterMelon with me and CocosDragon games for sample
22+
* Added Edit Box for input
1423

1524
Cocos2d-html5-v2.0.0 @ Aug.28, 2012
16-
* Updated API to Cocos2d-x V2.0.
17-
* Updated template and directory name.
18-
* Improved JS files loader.
19-
* Added support for Dom rendering.
20-
* Updated JSDoc comments and shell.
21-
* Added TileMap property process and flip.
22-
* Improved BMFont.
23-
* Added Actions spline paths and cc.AnimationFrame.
24-
* Added support for multi-touch.
25-
* Added mini-framework for Dom manipulation.
26-
* Changed cc.Animation, cc.AudioEngine, cc.LableTTF and cc.Sprite API.
25+
* Updated API to Cocos2d-x V2.0
26+
* Updated template and directory name
27+
* Improved JS files loader
28+
* Added support for Dom rendering
29+
* Updated JSDoc comments and shell
30+
* Added TileMap property process and flip
31+
* Improved BMFont
32+
* Added Actions spline paths and cc.AnimationFrame
33+
* Added support for multi-touch
34+
* Added mini-framework for Dom manipulation
35+
* Changed cc.Animation, cc.AudioEngine, cc.LableTTF and cc.Sprite API
2736

2837

2938
Cocos2d-html5-v0.5.0-alpha2 @ Jun.18, 2012
30-
* Changed API, use "create" to construct all objects.
31-
* Fixed naming of variables.
32-
* Added JSDoc comments and shell.
33-
* Fixed Dom Menu flicker bug.
34-
* Changed code for closure compiler Advance optional.
35-
* Added version control.
39+
* Changed API, use "create" to construct all objects
40+
* Fixed naming of variables
41+
* Added JSDoc comments and shell
42+
* Fixed Dom Menu flicker bug
43+
* Changed code for closure compiler Advance optional
44+
* Added version control
3645

3746
Cocos2d-html5-v0.5.0-alpha @ May.28, 2012
38-
* supports canvas and Dom Menu.
39-
* part of test cases were added and tested in chrome.
40-
* porting from cocos2d-x is not finished.
41-
* files must load from http server.
47+
* supports canvas and Dom Menu
48+
* part of test cases were added and tested in chrome
49+
* porting from cocos2d-x is not finished
50+
* files must load from http server
4251

4352
Cocos2d-html5-v0.1.0 @ Jan.29, 2012
4453
* Build the directory structure of Engine

Demo/NativeClientDemo/cocos2d.js

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
(function () {
2828
var d = document;
2929
var c = {
30-
menuType:'canvas', //whether to use canvas mode menu or dom menu
3130
COCOS2D_DEBUG:2, //0 to turn debug off, 1 for basic debug, and 2 for full debug
3231
box2d:false,
3332
chipmunk:false,

HelloHTML5World/build.xml

+32-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66

77
<target name="compile">
88
<jscomp compilationLevel="simple" warning="quiet"
9-
debug="false" output="myApp-v2.1.js">
9+
debug="false" output="myApp-HelloWorld.js">
1010
<sources dir="${basedir}/../cocos2d">
1111
<file name="platform/CCClass.js"/>
1212
<file name="platform/CCCommon.js"/>
13-
<file name="platform/platform.js"/>
1413
<file name="platform/miniFramework.js"/>
1514
<file name="platform/ZipUtils.js"/>
1615
<file name="platform/base64.js"/>
@@ -20,11 +19,13 @@
2019
<file name="platform/CCTypes.js"/>
2120
<file name="platform/zlib.min.js"/>
2221
<file name="cocoa/CCGeometry.js"/>
22+
<file name="platform/Sys.js"/>
2323
<file name="platform/CCConfig.js"/>
2424
<file name="cocoa/CCNS.js"/>
2525
<file name="cocoa/CCSet.js"/>
2626
<file name="cocoa/CCAffineTransform.js"/>
2727
<file name="support/CCPointExtension.js"/>
28+
<file name="support/CCUserDefault.js"/>
2829
<file name="base_nodes/CCNode.js"/>
2930
<file name="base_nodes/CCdomNode.js"/>
3031
<file name="base_nodes/CCAtlasNode.js"/>
@@ -93,6 +94,35 @@
9394
<sources dir="${basedir}/../CocosDenshion">
9495
<file name="SimpleAudioEngine.js"/>
9596
</sources>
97+
<!-- extensions -->
98+
<sources dir="${basedir}/../extensions">
99+
<file name="CCBReader/CCBReaderUtil.js"/>
100+
<file name="CCBReader/CCBValue.js"/>
101+
<file name="CCBReader/CCBKeyframe.js"/>
102+
<file name="CCBReader/CCBSequence.js"/>
103+
<file name="CCBReader/CCNodeLoader.js"/>
104+
<file name="CCBReader/CCBReader.js"/>
105+
<file name="CCBReader/CCControlLoader.js"/>
106+
<file name="CCBReader/CCSpriteLoader.js"/>
107+
<file name="CCBReader/CCNodeLoaderLibrary.js"/>
108+
<file name="CCBReader/CCBRelativePositioning.js"/>
109+
<file name="CCBReader/CCBAnimationManager.js"/>
110+
<file name="GUI/CCControlExtension/CCControl.js"/>
111+
<file name="GUI/CCControlExtension/CCControlButton.js"/>
112+
<file name="GUI/CCControlExtension/CCControlUtils.js"/>
113+
<file name="GUI/CCControlExtension/CCInvocation.js"/>
114+
<file name="GUI/CCControlExtension/CCScale9Sprite.js"/>
115+
<file name="GUI/CCControlExtension/CCControlSlider.js"/>
116+
<file name="GUI/CCControlExtension/CCControlSwitch.js"/>
117+
<file name="GUI/CCControlExtension/CCControlColourPicker.js"/>
118+
<file name="GUI/CCControlExtension/CCControlHuePicker.js"/>
119+
<file name="GUI/CCControlExtension/CCControlSaturationBrightnessPicker.js"/>
120+
<file name="GUI/CCControlExtension/CCMenuPassive.js"/>
121+
<file name="GUI/CCScrollView/CCSorting.js"/>
122+
<file name="GUI/CCScrollView/CCScrollView.js"/>
123+
<file name="GUI/CCScrollView/CCTableView.js"/>
124+
<file name="CCControlEditBox.js"/>
125+
</sources>
96126
<sources dir="${basedir}">
97127
<file name="src/resource.js"/>
98128
<file name="src/myApp.js"/>

cocos2d/CCDirector.js

+11-21
Original file line numberDiff line numberDiff line change
@@ -169,25 +169,23 @@ cc.Director = cc.Class.extend(/** @lends cc.Director# */{
169169
_watcherFun:null,
170170
_watcherSender:null,
171171

172-
_currTimeValue:null,
173172
_isBlur:false,
174173

175174
/**
176175
* Constructor
177176
*/
178177
ctor:function () {
179-
this._currTimeValue = new cc.timeval();
180-
this._lastUpdate = new cc.timeval();
178+
this._lastUpdate = Date.now();
181179
if(!cc.isAddedHiddenEvent){
182180
var selfPointer = this;
183181
window.addEventListener("focus",function(){
184-
selfPointer._lastUpdate = cc.Time.gettimeofdayCocos2d(selfPointer._lastUpdate);
182+
selfPointer._lastUpdate = Date.now();
185183
}, false);
186184
}
187185
},
188186

189187
_resetLastUpdate:function(){
190-
this._lastUpdate = cc.Time.gettimeofdayCocos2d(this._lastUpdate);
188+
this._lastUpdate = Date.now();
191189
},
192190

193191
/**
@@ -213,7 +211,7 @@ cc.Director = cc.Class.extend(/** @lends cc.Director# */{
213211
this._frameRate = 0;
214212
this._displayStats = false;//can remove
215213
this._totalFrames = this._frames = 0;
216-
this._lastUpdate = new cc.timeval();
214+
this._lastUpdate = Date.now();
217215

218216
//Paused?
219217
this._paused = false;
@@ -255,29 +253,22 @@ cc.Director = cc.Class.extend(/** @lends cc.Director# */{
255253
* calculates delta time since last time it was called
256254
*/
257255
calculateDeltaTime:function () {
258-
var now = cc.Time.gettimeofdayCocos2d(this._currTimeValue);
259-
if (!now) {
260-
cc.log("error in gettimeofday");
261-
this._deltaTime = 0;
262-
return;
263-
}
256+
var now = Date.now();
264257

265258
// new delta time.
266259
if (this._nextDeltaTimeZero) {
267260
this._deltaTime = 0;
268261
this._nextDeltaTimeZero = false;
269262
} else {
270-
this._deltaTime = (now.tv_sec - this._lastUpdate.tv_sec) + (now.tv_usec - this._lastUpdate.tv_usec) / 1000000.0;
271-
this._deltaTime = Math.max(0, this._deltaTime);
263+
this._deltaTime = (now-this._lastUpdate) / 1000;
272264
}
273265

274266
if (cc.DEBUG) {
275267
if (this._deltaTime > 0.2) {
276268
this._deltaTime = 1 / 60.0;
277269
}
278270
}
279-
this._lastUpdate.tv_sec = now.tv_sec;
280-
this._lastUpdate.tv_usec = now.tv_usec;
271+
this._lastUpdate = now;
281272
},
282273

283274
/**
@@ -668,7 +659,7 @@ cc.Director = cc.Class.extend(/** @lends cc.Director# */{
668659
//this.addRegionToDirtyRegion(cc.rect(0, 0, cc.canvas.width, cc.canvas.height));
669660

670661
this.setAnimationInterval(this._oldAnimationInterval);
671-
this._lastUpdate = cc.Time.gettimeofdayCocos2d();
662+
this._lastUpdate = Date.now();
672663
if (!this._lastUpdate) {
673664
cc.log("cocos2d: Director: Error in gettimeofday");
674665
}
@@ -1143,9 +1134,8 @@ cc.Director = cc.Class.extend(/** @lends cc.Director# */{
11431134
},
11441135

11451136
_calculateMPF:function () {
1146-
var now = cc.Time.gettimeofdayCocos2d();
1147-
1148-
this._secondsPerFrame = (now.tv_sec - this._lastUpdate.tv_sec) + (now.tv_usec - this._lastUpdate.tv_usec) / 1000000.0;
1137+
var now = Date.now();
1138+
this._secondsPerFrame = (now-this._lastUpdate)/1000;
11491139
}
11501140
});
11511141

@@ -1173,7 +1163,7 @@ cc.DisplayLinkDirector = cc.Director.extend(/** @lends cc.DisplayLinkDirector# *
11731163
* start Animation
11741164
*/
11751165
startAnimation:function () {
1176-
this._lastUpdate = cc.Time.gettimeofdayCocos2d();
1166+
this._nextDeltaTimeZero = true;
11771167
this.invalid = false;
11781168
cc.Application.sharedApplication().setAnimationInterval(this._animationInterval);
11791169
},

cocos2d/Draw_Nodes/CCDrawNode.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ cc.DrawNode = cc.Node.extend({
142142

143143
if (element.type === cc.DRAWNODE_TYPE_SEGMENT) {
144144
context.strokeStyle = "rgba(" + (0|(element.color.r * 255)) + "," + (0|(element.color.g * 255)) + "," + (0|(element.color.b * 255)) + "," + element.color.a + ")";
145-
context.lineWidth = element.radius;
145+
context.lineWidth = element.radius * 2;
146146
context.lineCap = "round";
147147
cc.drawingUtil.drawLine(element.from, element.to);
148148
}
@@ -151,11 +151,11 @@ cc.DrawNode = cc.Node.extend({
151151
context.fillStyle = "rgba(" + (0|(element.fillColor.r * 255)) + "," + (0|(element.fillColor.g * 255)) + ","
152152
+ (0|(element.fillColor.b * 255)) + "," + element.fillColor.a + ")";
153153
cc.drawingUtil.drawPoly(element.verts, element.count, false, true);
154-
context.lineWidth = element.borderWidth;
154+
context.lineWidth = element.borderWidth * 2;
155155
context.lineCap = "round";
156156
context.strokeStyle = "rgba(" + (0|(element.borderColor.r * 255)) + "," + (0|(element.borderColor.g * 255)) + ","
157157
+ (0|(element.borderColor.b * 255)) + "," + element.borderColor.a + ")";
158-
cc.drawingUtil.drawPoly(element.verts, element.count, false, false);
158+
cc.drawingUtil.drawPoly(element.verts, element.count, true, false);
159159
}
160160
}
161161

cocos2d/actions/CCActionEase.js

+6-10
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ cc.EaseExponentialOut = cc.ActionEase.extend(/** @lends cc.EaseExponentialOut# *
315315
* @param {Number} time1
316316
*/
317317
update:function (time1) {
318-
this._other.update(time1 == 1 ? 1 : (-(Math.pow(2, -10 * time1 )) + 1));
318+
this._other.update(time1 == 1 ? 1 : (-(Math.pow(2, -10 * time1)) + 1));
319319
},
320320

321321
/**
@@ -674,32 +674,28 @@ cc.EaseElasticInOut = cc.EaseElastic.extend(/** @lends cc.EaseElasticInOut# */{
674674
*/
675675
update:function (time1) {
676676
var newT = 0;
677-
if (time1 == 0 || time1 == 1) {
677+
if (time1 === 0 || time1 === 1) {
678678
newT = time1;
679679
} else {
680680
time1 = time1 * 2;
681-
if (!this._period) {
681+
if (!this._period)
682682
this._period = 0.3 * 1.5;
683-
}
684683

685684
var s = this._period / 4;
686-
687685
time1 = time1 - 1;
688-
if (time1 < 0) {
686+
if (time1 < 0)
689687
newT = -0.5 * Math.pow(2, 10 * time1) * Math.sin((time1 - s) * Math.PI * 2 / this._period);
690-
} else {
688+
else
691689
newT = Math.pow(2, -10 * time1) * Math.sin((time1 - s) * Math.PI * 2 / this._period) * 0.5 + 1;
692-
}
693690
}
694-
695691
this._other.update(newT);
696692
},
697693

698694
/**
699695
* @return {cc.ActionInterval}
700696
*/
701697
reverse:function () {
702-
return cc.EaseInOut.create(this._other.reverse(), this._period);
698+
return cc.EaseElasticInOut.create(this._other.reverse(), this._period);
703699
}
704700
});
705701

cocos2d/actions/CCActionInstant.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,9 @@ cc.CallFunc = cc.ActionInstant.extend(/** @lends cc.CallFunc# */{
284284
* @return {Boolean}
285285
*/
286286
initWithTarget:function (selector, selectorTarget, data) {
287-
this._data = data || null;
288-
this._callFunc = selector || null;
289-
this._selectorTarget = selectorTarget || null;
287+
this._data = data;
288+
this._callFunc = selector;
289+
this._selectorTarget = selectorTarget;
290290
return true;
291291
},
292292

0 commit comments

Comments
 (0)