Skip to content

Commit 0c29b2c

Browse files
committed
Merge branch 'develop' of https://github.com/cocos2d/cocos2d-html5 into Iss2530_ModifyLabelTTFStrokeStyle
2 parents 4065f89 + be04f75 commit 0c29b2c

File tree

4 files changed

+66
-47
lines changed

4 files changed

+66
-47
lines changed

cocos2d/base_nodes/CCdomNode.js

Lines changed: 63 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ cc.DOM.methods = /** @lends cc.DOM# */{
285285
redraw:function () {
286286
if (this.isSprite) {
287287
var tmp = this._children;
288-
this._children = null;
288+
this._children = [];
289289
cc.Sprite.prototype.visit.call(this, this.ctx);
290290
this._children = tmp;
291291
}
@@ -315,16 +315,25 @@ cc.DOM._resetEGLViewDiv = function(){
315315
}
316316

317317
eglViewDiv.style.position = 'absolute';
318-
eglViewDiv.style.bottom = 0;
319318
//x.dom.style.display='block';
320319
eglViewDiv.style.width = designSizeWidth + "px";
321320
eglViewDiv.style.maxHeight = designSizeHeight + "px";
322321
eglViewDiv.style.margin = 0;
323322

324323
eglViewDiv.resize(eglViewer.getScaleX(), eglViewer.getScaleY());
325-
eglViewDiv.style.left = ((viewPortWidth - designSizeWidth) / 2
326-
+ (screenSize.width - viewPortWidth ) / 2) + "px";
327-
eglViewDiv.style.bottom = ((screenSize.height - viewPortHeight ) / 2) + "px";
324+
325+
if (viewPortWidth < screenSize.width) {
326+
eglViewDiv.style.left = ((viewPortWidth - designSizeWidth) / 2
327+
+ (screenSize.width - viewPortWidth ) / 2) + "px";
328+
} else {
329+
eglViewDiv.style.left = (viewPortWidth - designSizeWidth) / 2 + "px";
330+
}
331+
332+
if (viewPortHeight < screenSize.height) {
333+
eglViewDiv.style.bottom = ((screenSize.height - viewPortHeight ) / 2) + "px";
334+
} else {
335+
eglViewDiv.style.bottom = "0px";
336+
}
328337
}
329338
};
330339

@@ -351,47 +360,56 @@ cc.DOM.parentDOM = function (x) {
351360
cc.DOM.parentDOM(p);
352361
} else {
353362
//parent has no more parent, if its running, then add it to the container
354-
//if (p.isRunning()) {
355-
//find EGLView div
356-
var eglViewDiv = cc.$("#EGLViewDiv");
357-
if(eglViewDiv){
358-
p.dom.appendTo(eglViewDiv);
359-
} else {
360-
eglViewDiv = cc.$new("div");
361-
eglViewDiv.id = "EGLViewDiv";
362-
363-
var eglViewer = cc.EGLView.getInstance();
364-
var designSize = eglViewer.getDesignResolutionSize();
365-
var viewPortRect = eglViewer.getViewPortRect();
366-
var screenSize = eglViewer.getFrameSize();
367-
var designSizeWidth = designSize.width, designSizeHeight = designSize.height;
368-
if((designSize.width === 0) && (designSize.height === 0)){
369-
designSizeWidth = screenSize.width;
370-
designSizeHeight = screenSize.height;
371-
}
372-
373-
var viewPortWidth = viewPortRect.size.width, viewPortHeight = viewPortRect.size.height;
374-
if((viewPortRect.size.width === 0) && (viewPortRect.size.height === 0)){
375-
viewPortWidth = screenSize.width;
376-
viewPortHeight = screenSize.height;
363+
if (p.isRunning()) {
364+
//find EGLView div
365+
var eglViewDiv = cc.$("#EGLViewDiv");
366+
if (eglViewDiv) {
367+
p.dom.appendTo(eglViewDiv);
368+
} else {
369+
eglViewDiv = cc.$new("div");
370+
eglViewDiv.id = "EGLViewDiv";
371+
372+
var eglViewer = cc.EGLView.getInstance();
373+
var designSize = eglViewer.getDesignResolutionSize();
374+
var viewPortRect = eglViewer.getViewPortRect();
375+
var screenSize = eglViewer.getFrameSize();
376+
var designSizeWidth = designSize.width, designSizeHeight = designSize.height;
377+
if ((designSize.width === 0) && (designSize.height === 0)) {
378+
designSizeWidth = screenSize.width;
379+
designSizeHeight = screenSize.height;
380+
}
381+
382+
var viewPortWidth = viewPortRect.size.width, viewPortHeight = viewPortRect.size.height;
383+
if ((viewPortRect.size.width === 0) && (viewPortRect.size.height === 0)) {
384+
viewPortWidth = screenSize.width;
385+
viewPortHeight = screenSize.height;
386+
}
387+
388+
eglViewDiv.style.position = 'absolute';
389+
//x.dom.style.display='block';
390+
eglViewDiv.style.width = designSizeWidth + "px";
391+
eglViewDiv.style.maxHeight = designSizeHeight + "px";
392+
eglViewDiv.style.margin = 0;
393+
394+
eglViewDiv.resize(eglViewer.getScaleX(), eglViewer.getScaleY());
395+
396+
if (viewPortWidth < screenSize.width) {
397+
eglViewDiv.style.left = ((viewPortWidth - designSizeWidth) / 2
398+
+ (screenSize.width - viewPortWidth ) / 2) + "px";
399+
} else {
400+
eglViewDiv.style.left = (viewPortWidth - designSizeWidth) / 2 + "px";
401+
}
402+
403+
if (viewPortHeight < screenSize.height) {
404+
eglViewDiv.style.bottom = ((screenSize.height - viewPortHeight ) / 2) + "px";
405+
} else {
406+
eglViewDiv.style.bottom = "0px";
407+
}
408+
409+
p.dom.appendTo(eglViewDiv);
410+
eglViewDiv.appendTo(cc.container);
377411
}
378-
379-
eglViewDiv.style.position = 'absolute';
380-
eglViewDiv.style.bottom = 0;
381-
//x.dom.style.display='block';
382-
eglViewDiv.style.width = designSizeWidth + "px";
383-
eglViewDiv.style.maxHeight = designSizeHeight + "px";
384-
eglViewDiv.style.margin = 0;
385-
386-
eglViewDiv.resize(eglViewer.getScaleX(), eglViewer.getScaleY());
387-
eglViewDiv.style.left = ((viewPortWidth - designSizeWidth) / 2
388-
+ (screenSize.width - viewPortWidth ) / 2) + "px";
389-
eglViewDiv.style.bottom = ((screenSize.height - viewPortHeight ) / 2) + "px";
390-
391-
p.dom.appendTo(eglViewDiv);
392-
eglViewDiv.appendTo(cc.container);
393412
}
394-
//}
395413
}
396414
return true;
397415
};
@@ -410,7 +428,7 @@ cc.DOM.setTransform = function (x) {
410428
x.ctx.translate(x.getAnchorPointInPoints().x, x.getAnchorPointInPoints().y);
411429
if (x.isSprite) {
412430
var tmp = x._children;
413-
x._children = null;
431+
x._children = [];
414432
cc.Sprite.prototype.visit.call(x, x.ctx);
415433
x._children = tmp;
416434
}

cocos2d/label_nodes/CCLabelTTF.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1272,7 +1272,7 @@ cc.LabelTTFWebGL = cc.Sprite.extend(/** @lends cc.LabelTTFWebGL# */{
12721272
},
12731273

12741274
setPosition:function(posX, posY){
1275-
if(posY)
1275+
if (arguments.length == 2)
12761276
this._originalPosition = cc.p(posX, posY);
12771277
else
12781278
this._originalPosition = cc.p(posX.x, posX.y);

cocos2d/platform/CCFileUtils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ cc.FileUtils = cc.Class.extend({
279279
xhr.onload = function (e) {
280280
if (xhr.responseText) {
281281
cc.Loader.getInstance().onResLoaded();
282-
selfPointer._fileDataCache[fileUrl] = xhr.responseText;
282+
selfPointer._textFileCache[fileUrl] = xhr.responseText;
283283
}
284284
};
285285
}

extensions/GUI/CCControlExtension/CCScale9Sprite.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{
230230

231231
setCapInsets: function (capInsets) {
232232
var contentSize = this._contentSize;
233+
contentSize = new cc.Size(contentSize.width,contentSize.height);
233234
this.updateWithBatchNode(this._scale9Image, this._spriteRect, this._spriteFrameRotated, capInsets);
234235
this.setContentSize(contentSize);
235236
},

0 commit comments

Comments
 (0)