admin 发表于 2021-11-21 10:36:18

教程2 官方内置控件测试



--本代码支持二建端直接执行看效果
--以下代码可以实时在浏览器中编辑修改 并执行查看效果

TESTLoader = new.www('http://bbs.ml30.com/gacenter/Iselect/')
-- 创建一个窗口
cc.view =
{   
    title = 'Itest1';--窗口名
    xpos = 120; ypos = 200; --初始坐标
    sizex = 504; sizey = 327; pxpos = 504; pypos = 50;--窗口大小/可拖动区域坐标X(0~504) Y(0~50)

    on_init= function(view)    --当窗口初始化

    end;
    on_load= function(view)    --当窗口开始创建

    end;
};

-- 放一个bmp的背景板
cc.bmpbutton =
{
      args = { TESTLoader.Uget('bg2.bmp') };         --控件的图档
      title = 'bg';                --控件名
      xpos = 0; ypos = 0;          --注意:这里的坐标是相对坐标 以view的坐标为基准 即屏幕坐标=view坐标+本控件坐标
      on_load = function(object)         

      end;
      on_event = function(object)
            object.id = TESTLoader.Uwait('bg2.bmp')
      end;
};

-- 放一个关闭按钮 这是一个封装好的按钮
cc.closebutton =
{
      title = 'Iclose';
      xpos = 461; ypos = 9;
      event = function ( object )--当玩家点击关闭按钮时会触发event事件 返回1允许关闭 返回0不允许
                Audio.Bell(54,320)
                return 1;
      end
};

for i=1,3 do
cc.textbox =
{
        title = 'textbox1'..i;
        xpos = 50;
        ypos = 50+i*20;
        color = 6+i;
        fontsize = 1;
        text = "哈哈哈 "..i;
       
}
end

cc.anime =
{
        title = 'anime1';
        xpos = 120;
        ypos = 50;
        animeID = 100086;
        dir = 4;
        action = 0;

       
}

cc.listbox =
{
        title = 'listbox1';
        args = {10};
        xpos = 100;
        ypos = 50;
        data ={
        "昆虫系",
        "昆虫系",
        " ",
        " ",
        " ",
        " ",
        " ",
        " ",
        " ",
        "植物系"
        };
       

       
}

cc.comlistbox =
{
        title = 'comlistbox1';
        args = {10};
        xpos = 320;
        ypos = 50;
        data ={
        "昆虫系",
        "昆虫系",
        " ",
        " ",
        " ",
        " ",
        " ",
        " ",
        " ",
        "植物系"
        };
       

       
}


cc.inputbox =
{
        title = 'inputbox1';
        xpos = 180;
        ypos = -10;
        sizex = 120;
        sizey = 20;
        event = function(object,event)
       this.spComBox(object.mainview.xpos + object.xpos,object.mainview.ypos + object.ypos,object.mainview.xpos + object.xpos + object.sizex,object.mainview.ypos + object.ypos + object.sizey,10,0)
       if event == Cevent.click then

       end
       if object.isfirstfocus() then
         object.settext(object.text)
       end
       if object.isfocus() then
         object.settext(object.text)
       end
       if not object.isfocus() then
          this.spText(object.mainview.xpos + object.xpos,object.mainview.ypos + object.ypos,object.fontsize,object.text)
       end
        end

       
}


<?
function gacenter.finish(player)
      NLG.SystemMessage(player,"[提示] 测试脚本执行完成.")      

      Client.RunABundle(player,'__WEBFILE__')      
      Client.Show(player,'Itest1')
      
end
?>








页: [1]
查看完整版本: 教程2 官方内置控件测试