| 
 
注册时间2015-10-23最后登录2016-8-25 
 游戏开发者 
 
	积分14 
 | 
 
 
 楼主|
发表于 2015-12-3 09:28:15
|
显示全部楼层 
| 本帖最后由 瑭谈音 于 2015-12-3 17:04 编辑 
 D大我又有新问题了_(:зゝ∠)_是道具系统按钮上文字那一部分的。
 一开始我没有注意到,今天做测试的时候发现,必须把鼠标移动到按钮上才会显示物品数量,而不像是D大你给出的范例,只要打开界面就会显示数量,我自己对比了一下感觉没啥差别啊……我还是把代码贴出来D大你帮忙看一下吧……
 macro_item_ui的,macro_item的我没有动。
 
 复制代码[iscript]
function draw_item()
{
        //------【修改排版的位置】------
        
        //设定每页显示的物品数量
        var per_num=11;
        //设定按钮位置
        var x=236;
        var y=61;
        //设定按钮间距
        var line_space=38;
        
        //---------------------------------
        
        //计算物品页数
        f.物品总页数=f.item.count\per_num;
        if (f.item.count%per_num>0) f.物品总页数++;
        
        //假如物品总页数<1,说明不存在物品,那么就不继续了
        if (f.物品总页数<1) 
        {
                f.当前物品页=0;
                return;
        }
        
        //保证当前物品页不为0,且不超过物品总页数
        if (f.当前物品页<1) f.当前物品页=1;
        if (f.当前物品页>f.物品总页数) f.当前物品页=f.物品总页数;
        
        for (var i=0;i<per_num;i++)
        {
                 //准备显示的物品编号
            var item_index=(int)(f.当前物品页-1)*per_num+(int)i;
                    //假如超过了物品列表总数(最后一页物品已经显示完毕),跳出循环
             if (item_index>=f.item.count) break;
             
             //假如没有超过,继续显示
                        //用TJS的方式设定按钮坐标
                     kag.tagHandlers.locate(%["x" => x, "y" => y+i*line_space ]);
                     
                     //【描绘小函数1】创建物品按钮
                        draw_item_button(item_index);
                     //【描绘小函数2】在物品按钮上描绘物品名称和数量
                     draw_item_name(item_index);
        }
}
[endscript]
;---------------------------------------描绘小函数1:创建单个物品按钮---------------------------------------
[iscript]
function draw_item_button(item_index)
{
         //设定物品按钮的具体属性
         var mybutton=new Dictionary();
         
         //【修改按钮图形】
         mybutton.normal="物品条1";
         mybutton.over="物品条2";
         
         //【悬停效果函数】设定鼠标移动到物品按钮上和离开时的效果
         //mybutton.onenter="draw_item_icon("+item_index+")";
         //mybutton.onleave="hide_item_icon()";
         
         //设定按钮按下后的效果,跳转到标签 *物品数据
         mybutton.target="*物品数据";
         //按下后会将物品编号赋值给 f.选择物品编号 这个变数
         mybutton.exp="f.选择物品编号="+item_index;
         
         //用tjs的方式创建按钮
         kag.tagHandlers.button(mybutton);
         
}
[endscript]
;---------------------------------------描绘小函数2:描绘物品按钮上的文字---------------------------------------
[iscript]
function draw_item_name(item_index)
{
        var mybutton=kag.current.links[kag.current.links.count-1].object;
        
        //字体大小
        mybutton.font.height=18;
        mybutton.font.face=kag.fore.messages[0].userFace;
        //根据传入的编号取得物品名称
        var str=f.item[item_index].name;
        
        //文字在按钮上的坐标
        var x=18;
        var y=10;
        //描绘物品名称
        mybutton.drawText(x,                           y, str, 0xc9c9c9);
        mybutton.drawText(x+mybutton.width,              y, str, 0xc9c9c9);
        mybutton.drawText(x+mybutton.width+mybutton.width, y, str, 0xc9c9c9);
        
        //取得物品数量
        var str=f.item[item_index].num;
        //文字在按钮上的坐标
        var x=400;
        var y=10;
        //描绘物品数量
        mybutton.drawText(x,                           y, str, 0xc9c9c9);
        mybutton.drawText(x+mybutton.width,              y, str, 0xc9c9c9);
        mybutton.drawText(x+mybutton.width+mybutton.width, y, str, 0xc9c9c9);
}
[endscript]
此外还有一个问题,比如我现在系统设定的是玩家得到配方,学习配方后才能合成,我如何让配方不需要重复学习?
 复制代码*配方数据
@backlay
@image layer=15 storage="itemectbgd" visible="true"
@eval exp='draw_recipe_icon(f.选择配方编号)'
@eval exp="f.制作=f.recipe[f.选择配方编号].edu"
@call target="*刷新配方"
@s
;------------------------------------------------------------
*使用配方
[iscript]
//在控制台输出配方名称
dm("选择使用配方:"+f.recipe[f.选择配方编号].name);
[endscript]
;可以在这里写一些判断
;【例如】假如物品可以学习,那么每次点击减少一个物品
@if exp="f.recipe[f.选择配方编号].edu==0"
@subrecipe num="1" name=&"f.recipe[f.选择配方编号].name"
@eval exp="f.recipe[f.选择配方编号].edu=1"
@endif
@jump target="*刷新配方"
@s
这样写代码的话,程序会报错,说无法将void转变为object……
 
 | 
 |