Skip to content

Feature #3163 change animation display by name #1222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions extensions/CocoStudio/Armature/display/CCDisplayManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,28 @@ ccs.DisplayManager = ccs.Class.extend({
}
this.setCurrentDecorativeDisplay(decoDisplay);
},
changeDisplayByName:function (name, force){
var decoDisplay;
this._forceChangeDisplay = force;

for(var index = 0; index < this._decoDisplayList.length;index++){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,jandujar.
Thank you very much to your commit. That is a good idea to add this api .
I modify your code like:

    var decoDisplay, displayIndex;
    for (var i = 0; i < this._decoDisplayList.length; i++) {
        var locDecoDisplay = this._decoDisplayList[i];
        var locDisplay = locDecoDisplay.getDisplay();
        if ((typeof(locDisplay.getDisplayName) != "undefined") && name == locDisplay.getDisplayName()) {
            decoDisplay = locDecoDisplay;
            displayIndex = i;
            break;
        }
    }
    if (!decoDisplay) {) {
        return;
    }
    this._forceChangeDisplay = force;
    this._displayIndex = displayIndex;
    this.setCurrentDecorativeDisplay(decoDisplay);

var display = this._decoDisplayList[index].getDisplay();
if( (typeof(display.getDisplayName) != "undefined") && name == this._decoDisplayList[index].getDisplay().getDisplayName()){
decoDisplay = this._decoDisplayList[index];
this._displayIndex = index;
break;
}
}


if(!decoDisplay){
return;
}


this.setCurrentDecorativeDisplay(decoDisplay);

},

changeDisplayWithName: function (name, force) {
for (var i = 0; i < this._decoDisplayList.length; i++) {
Expand Down
16 changes: 8 additions & 8 deletions extensions/CocoStudio/Reader/SceneReader.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,25 +348,25 @@ ccs.SceneReader = ccs.Class.extend(/** @lends ccs.SceneReader# */{
* @param {Object} dict
*/
setPropertyFromJsonDict: function (node, dict) {
var x = dict["x"] || 0;
var y = dict["y"] || 0;
var x = (typeof dict["x"] === 'undefined')?0:dict["x"];
var y = (typeof dict["y"] === 'undefined')?0:dict["y"];
node.setPosition(cc.p(x, y));

var bVisible = Boolean(dict["visible"] || 1);
var bVisible = Boolean((typeof dict["visible"] === 'undefined')?1:dict["visible"]);
node.setVisible(bVisible);

var nTag = dict["objecttag"] || -1;
var nTag = (typeof dict["objecttag"] === 'undefined')?-1:dict["objecttag"];
node.setTag(nTag);

var nZorder = dict["zorder"] || 0;
var nZorder = (typeof dict["zorder"] === 'undefined')?0:dict["zorder"];
node.setZOrder(nZorder);

var fScaleX = dict["scalex"] || 1;
var fScaleY = dict["scaley"] || 1;
var fScaleX = (typeof dict["scalex"] === 'undefined')?1:dict["scalex"];
var fScaleY = (typeof dict["scaley"] === 'undefined')?1:dict["scaley"];
node.setScaleX(fScaleX);
node.setScaleY(fScaleY);

var fRotationZ = dict["rotation"] || 0;
var fRotationZ = (typeof dict["rotation"] === 'undefined')?0:dict["rotation"];
node.setRotation(fRotationZ);
},
setTarget : function(selector,listener){
Expand Down