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
    评论
您可以通过为Button设置一个StateListDrawable来实现Button点击时的光晕效果,具体步骤如下: 1. 在drawable目录下创建一个selector文件,例如:button_selector.xml ```xml <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/button_pressed" android:state_pressed="true"/> <item android:drawable="@drawable/button_normal"/> </selector> ``` 2. 在drawable目录下创建button_pressed.xml和button_normal.xml文件,分别表示按钮点击和未点击时的状态 button_pressed.xml: ```xml <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="#33000000"/> <corners android:radius="50dp"/> </shape> ``` button_normal.xml: ```xml <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="#000000"/> <corners android:radius="50dp"/> </shape> ``` 3. 在布局文件中将Button的background设置为button_selector.xml即可实现光晕效果 ```xml <Button android:id="@+id/btn_test" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" android:background="@drawable/button_selector"/> ``` 当按钮被点击时,会显示一个半透明的圆形光晕,效果如下: ![button_pressed](https://img-blog.csdn.net/20180823144913744?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3BhcnRpY2lwYW50X2Jsb2c=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/q/80)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值