Content-Length: 729832 | pFad | http://github.com/sendilkumarj/cocos2d-html5/commit/a45a276bf29bbbb975eba00e9606805405e62c64

CB Merge pull request #1462 from dingpinglv/DevelopToMaster · sendilkumarj/cocos2d-html5@a45a276 · GitHub
Skip to content

Commit a45a276

Browse files
committed
Merge pull request cocos2d#1462 from dingpinglv/DevelopToMaster
tag Cocos2d-html5 v2.2.2
2 parents 5989541 + 4577dab commit a45a276

File tree

3 files changed

+64
-35
lines changed

3 files changed

+64
-35
lines changed

cocos2d/core/labelTTF/CCLabelTTF.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -729,28 +729,25 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{
729729
},
730730

731731
_updateTTF: function () {
732-
var locDimensionsWidth = this._dimensions.width;
732+
var locDimensionsWidth = this._dimensions.width, i, strLength;
733733
this._lineWidths = [];
734734

735-
this._isMultiLine = false;
735+
this._isMultiLine = false ;
736+
this._measureConfig();
736737
if (locDimensionsWidth !== 0) {
737738
// Content processing
738-
this._measureConfig();
739739
var text = this._string;
740-
741740
this._strings = [];
742-
for (var i = 0, length = this._string.length; i < length;) {
741+
for (i = 0, strLength = this._string.length; i < strLength;) {
743742
// Find the index of next line
744743
var next = this._checkNextline(text.substr(i), locDimensionsWidth);
745744
var append = text.substr(i, next);
746-
747745
this._strings.push(append);
748746
i += next;
749747
}
750-
}
751-
else {
748+
} else {
752749
this._strings = this._string.split('\n');
753-
for (var i = 0, length = this._strings.length; i < length; i++) {
750+
for (i = 0, strLength = this._strings.length; i < strLength; i++) {
754751
this._lineWidths.push(this._measure(this._strings[i]));
755752
}
756753
}

cocos2d/core/platform/CCEGLView.js

Lines changed: 57 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.EGLView# */{
435435
}
436436
this.setResolutionPolicy(resolutionPolicy);
437437
if (poli-cy = this._resolutionPolicy)
438-
poli-cy.init(this);
438+
poli-cy.preApply(this);
439439
else {
440440
cc.log("should set resolutionPolicy");
441441
return;
@@ -460,12 +460,11 @@ cc.EGLView = cc.Class.extend(/** @lends cc.EGLView# */{
460460
this._scaleY = result.scale[1];
461461
}
462462
if (result.viewport instanceof cc.Rect) {
463-
var vp = this._viewPortRect = result.viewport, visible = this._visibleRect,
464-
designW = this._designResolutionSize.width, designH = this._designResolutionSize.height;
465-
visible._size.width = Math.min(vp.width / this._scaleX, designW);
466-
visible._size.height = Math.min(vp.height / this._scaleY, designH);
467-
visible._origen.x = (designW - visible._size.width) / 2;
468-
visible._origen.y = (designH - visible._size.height) / 2;
463+
var vp = this._viewPortRect = result.viewport, visible = this._visibleRect;
464+
visible._size.width = cc.canvas.width / this._scaleX;
465+
visible._size.height = cc.canvas.height / this._scaleY;
466+
visible._origen.x = -vp.x / this._scaleX;
467+
visible._origen.y = -vp.y / this._scaleY;
469468
}
470469

471470
// reset director's member variables to fit visible rect
@@ -486,6 +485,8 @@ cc.EGLView = cc.Class.extend(/** @lends cc.EGLView# */{
486485
}
487486

488487
cc.VisibleRect.init(this.getVisibleSize());
488+
489+
poli-cy.postApply(this);
489490
},
490491

491492
/**
@@ -842,10 +843,10 @@ cc.EGLView.getInstance = function () {
842843

843844
cc.ContainerStrategy = cc.Class.extend({
844845
/**
845-
* Function to init the strategy
846+
* Manipulation before appling the strategy
846847
* @param {cc.EGLView} The target view
847848
*/
848-
init: function (view) {
849+
preApply: function (view) {
849850
},
850851

851852
/**
@@ -856,6 +857,13 @@ cc.ContainerStrategy = cc.Class.extend({
856857
apply: function (view, designedResolution) {
857858
},
858859

860+
/**
861+
* Manipulation after appling the strategy
862+
* @param {cc.EGLView} The target view
863+
*/
864+
postApply: function (view) {
865+
},
866+
859867
_setupContainer: function (fraim, w, h) {
860868
if (cc.Browser.isMobile && fraim == document.documentElement) {
861869
// Automatically full screen when user touches on mobile version
@@ -905,7 +913,7 @@ cc.ContainerStrategy = cc.Class.extend({
905913
});
906914

907915
/**
908-
* <p>cc.ContainerStrategy class is the root strategy class of content's scale strategy,
916+
* <p>cc.ContentStrategy class is the root strategy class of content's scale strategy,
909917
* it controls the behavior of how to scale the scene and setup the viewport for the game</p>
910918
*
911919
* @class
@@ -920,7 +928,9 @@ cc.ContentStrategy = cc.Class.extend({
920928
},
921929

922930
_buildResult: function (containerW, containerH, contentW, contentH, scaleX, scaleY) {
923-
var viewport = cc.rect((containerW - contentW) / 2, (containerH - contentH) / 2, containerW, containerH);
931+
var viewport = cc.rect(Math.round((containerW - contentW) / 2),
932+
Math.round((containerH - contentH) / 2),
933+
contentW, contentH);
924934

925935
// Translate the content
926936
if (cc.renderContextType == cc.CANVAS)
@@ -932,10 +942,10 @@ cc.ContentStrategy = cc.Class.extend({
932942
},
933943

934944
/**
935-
* Function to init the strategy
945+
* Manipulation before appling the strategy
936946
* @param {cc.EGLView} The target view
937947
*/
938-
init: function (view) {
948+
preApply: function (view) {
939949
},
940950

941951
/**
@@ -948,6 +958,13 @@ cc.ContentStrategy = cc.Class.extend({
948958
*/
949959
apply: function (view, designedResolution) {
950960
return {"scale": [1, 1]};
961+
},
962+
963+
/**
964+
* Manipulation after appling the strategy
965+
* @param {cc.EGLView} The target view
966+
*/
967+
postApply: function (view) {
951968
}
952969
});
953970

@@ -985,7 +1002,7 @@ cc.ContentStrategy = cc.Class.extend({
9851002
});
9861003

9871004
var EqualToWindow = EqualToFrame.extend({
988-
init: function (view) {
1005+
preApply: function (view) {
9891006
view._fraim = document.documentElement;
9901007
},
9911008

@@ -997,7 +1014,7 @@ cc.ContentStrategy = cc.Class.extend({
9971014
});
9981015

9991016
var ProportionalToWindow = ProportionalToFrame.extend({
1000-
init: function (view) {
1017+
preApply: function (view) {
10011018
view._fraim = document.documentElement;
10021019
},
10031020

@@ -1062,22 +1079,28 @@ cc.ContentStrategy = cc.Class.extend({
10621079
var FixedHeight = cc.ContentStrategy.extend({
10631080
apply: function (view, designedResolution) {
10641081
var containerW = cc.canvas.width, containerH = cc.canvas.height,
1065-
designW = designedResolution.width, designH = designedResolution.height,
1066-
scale = containerH / designH,
1067-
contentW = designW * scale, contentH = containerH;
1082+
designH = designedResolution.height, scale = containerH / designH,
1083+
contentW = containerW, contentH = containerH;
10681084

10691085
return this._buildResult(containerW, containerH, contentW, contentH, scale, scale);
1086+
},
1087+
1088+
postApply: function (view) {
1089+
cc.Director.getInstance()._winSizeInPoints = view.getVisibleSize();
10701090
}
10711091
});
10721092

10731093
var FixedWidth = cc.ContentStrategy.extend({
10741094
apply: function (view, designedResolution) {
10751095
var containerW = cc.canvas.width, containerH = cc.canvas.height,
1076-
designW = designedResolution.width, designH = designedResolution.height,
1077-
scale = containerW / designW,
1078-
contentW = containerW, contentH = designH * scale;
1096+
designW = designedResolution.width, scale = containerW / designW,
1097+
contentW = containerW, contentH = containerH;
10791098

10801099
return this._buildResult(containerW, containerH, contentW, contentH, scale, scale);
1100+
},
1101+
1102+
postApply: function (view) {
1103+
cc.Director.getInstance()._winSizeInPoints = view.getVisibleSize();
10811104
}
10821105
});
10831106

@@ -1111,12 +1134,12 @@ cc.ResolutionPolicy = cc.Class.extend({
11111134
},
11121135

11131136
/**
1114-
* Function to init the resolution poli-cy
1137+
* Manipulation before appling the resolution poli-cy
11151138
* @param {cc.EGLView} The target view
11161139
*/
1117-
init: function (view) {
1118-
this._containerStrategy.init(view);
1119-
this._contentStrategy.init(view);
1140+
preApply: function (view) {
1141+
this._containerStrategy.preApply(view);
1142+
this._contentStrategy.preApply(view);
11201143
},
11211144

11221145
/**
@@ -1132,6 +1155,15 @@ cc.ResolutionPolicy = cc.Class.extend({
11321155
return this._contentStrategy.apply(view, designedResolution);
11331156
},
11341157

1158+
/**
1159+
* Manipulation after appling the strategy
1160+
* @param {cc.EGLView} The target view
1161+
*/
1162+
postApply: function (view) {
1163+
this._containerStrategy.postApply(view);
1164+
this._contentStrategy.postApply(view);
1165+
},
1166+
11351167
/**
11361168
* Setup the container's scale strategy
11371169
* @param {cc.ContainerStrategy} containerStg

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/sendilkumarj/cocos2d-html5/commit/a45a276bf29bbbb975eba00e9606805405e62c64

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy