jsb 实现简单的读取ui,ui里的动画,button按钮事件,执行动画代码

var MainScene = function(){};MainScene.prototype.onDidLoadFromCCB = function(){    cc.log("加载成功");    this._uiLayer = ccs.UILayer.create();    this.rootNode.addChild(this._uiLayer);
摘要由CSDN通过智能技术生成

var MainScene = function(){};


MainScene.prototype.onDidLoadFromCCB = function()

{

    cc.log("加载成功");

    this._uiLayer = ccs.UILayer.create();

    this.rootNode.addChild(this._uiLayer);

    

    this._widget = ccs.GUIReader.getInstance().widgetFromJsonFile("res/MenuUI_1.json");

    

    this._uiLayer.addWidget(this._widget);

    

    

    //获取点击按钮

    var button = this._uiLayer.getWidgetByName("Button_23");

    //设置按钮点击事件响应

    button.addTouchEventListener(this.touchEvent,this);

    


};

// 点击button事件

MainScene.prototype.touchEvent = function (sender, type) {

    switch (type) {

        case ccs.TouchEventType.began:

            ccs.ActionManager.getInstance().playActionByName("MenuUI_1.json","Animation0");

            break;

        default:

            break;

    }

}

MainScene.prototype.next = function()

{

    var sp = cc.Sprite.create("01.png");

    sp.setPosition(300,300);

    

    this.rootNode.addChild(sp);

    

    cc.log("按住nextbtn");

    

    this.ttt();

    // 启动定时器

    //this.rootNode.schedule(this.ttt,1)

    

};

MainScene.prototype.ttt = function()

{

    //cc.log("定时器1")


    ccs.ActionManager.getInstance().playActionByName("MenuUI_1.json","Animation0");

    


};









-----------------------------------------————————————————执行动画——————————————————————————————————————————


var s_Dragon_plist = "res/Dragon.plist";

var s_Dragon_png = "res/Dragon.png";

var s_Dragon_xml = "res/Dragon.xml";


var s_Cowboy_json = "res/Cowboy.ExportJson";

var s_Cowboy_plist = "res/Cowboy0.plist";

var s_Cowboy_png = "res/Cowboy0.png";


var ArmatureTestLayer = cc.Layer.extend({

     ctor:function () {

                                        this._super();

                                        cc.associateWithNative( this, cc.Layer );

                                        

                                        

                                        

                                        

                                        

                                        

                                        ccs.ArmatureDataManager.getInstance().addArmatureFileInfo(s_Cowboy_json);

                                        var armature = ccs.Armature.create("Cowboy");

                                        //armature.getAnimation().playWithIndex(0);

                                        armature.getAnimation().play("FireWithoutBullet");

                                        armature.getAnimation().setSpeedScale(0.4);

                                        armature.setScale(0.6);

                                        armature.setAnchorPoint(0.5, 0.5);

                                        armature.setPosition(300, 300);

                                        this.addChild(armature);

                                        

                                        

                                        

                                        

//                                        ccs.ArmatureDataManager.getInstance().addArmatureFileInfo(s_Dragon_png, s_Dragon_plist, s_Dragon_xml);

//                                        var armature = ccs.Armature.create("Dragon");

//                                        armature.getAnimation().playWithIndex(0);

//                                        //armature.getAnimation().play("Dragon");

//                                        armature.getAnimation().setSpeedScale(0.4);

//                                        armature.setScale(0.6);

//                                        armature.setAnchorPoint(0.5, 0.5);

//                                        armature.setPosition(300, 300);

//                                        this.addChild(armature);


     }

     

    

 });













  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值