设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2342|回复: 8
打印 上一主题 下一主题

[有事请教] 如何跳過CategoryWindow選擇視窗,直接在itemWindow繪製道具

[复制链接]

Lv1.梦旅人

梦石
0
星屑
132
在线时间
291 小时
注册时间
2013-1-10
帖子
102
跳转到指定楼层
1
发表于 2019-2-4 00:58:06 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
本帖最后由 xcv15963 于 2019-2-5 17:53 编辑

Scene_Mixing.prototype.createItemWindow = function() {
    this._itemWindow = new Window_ItemList(0, 0, 400, 400);
    this._itemWindow.setHandler('ok',     this.onItemOk.bind(this));
    this._itemWindow.setHandler('cancel', this.popScene.bind(this));
    this._itemWindow.activate();
    this._itemWindow.selectLast();
    this.addWindow(this._itemWindow);
    this._itemWindow.setItemWindow(this._itemWindow);
    this._category = 'item';
};

Scene_Mixing.prototype.useItem = function() {
    Scene_ItemBase.prototype.useItem.call(this);
    this._itemWindow.redrawCurrentItem();
};

// Scene_Mixing.prototype.onCategoryOk = function() {
//     this._itemWindow.activate();
//     this._itemWindow.selectLast();
// };

Scene_Mixing.prototype.onItemOk = function() {
    $gameParty.setLastItem(this.item());
    this.determineItem();
};

// Scene_Mixing.prototype.onItemCancel = function() {
//     this._itemWindow.deselect();
//     this._categoryWindow.activate();
// };

Scene_Mixing.prototype.useItem = function() {
    Scene_ItemBase.prototype.useItem.call(this);
    this._itemWindow.redrawCurrentItem();
};

Window_ItemList.prototype.setItemWindow = function(itemWindow) {
    this._itemWindow = itemWindow;
};

Window_ItemList.prototype.includes = function(item) {
    DataManager.isItem(item) && item.itypeId === 1;
};

程式碼是這樣子的↑↑
請問如果我想跳過createCategoryWindow 選擇道具的視窗,
直接就在itemWindow 繪製身上有的消耗類道具,該怎麼做呢?
我有試著直接指定this._category = item ,但是好像沒什麼用......

有視窗.png (113.17 KB, 下载次数: 6)

目前有一個新的視窗,但是裡面沒有東西。

目前有一個新的視窗,但是裡面沒有東西。

Lv4.逐梦者

梦石
0
星屑
12157
在线时间
4435 小时
注册时间
2014-4-11
帖子
5955

开拓者

2
发表于 2019-2-4 16:38:04 | 只看该作者
createCategoryWindow 要进入itemWindow
是什么原理应该先搞清楚。
也就是在createCategoryWindow 上点击一下进入的
this._categoryWindow.setHandler('ok',     this.onCategoryOk.bind(this));
也就是这一条
当按下OK就执行this.onCategoryOk
所以我们找一下onCategoryOk
找到的是
Scene_Item.prototype.onCategoryOk = function() {
    this._itemWindow.activate();
    this._itemWindow.selectLast();
};
也就是itemWindow变成可操作
但是这样还看不到itemWindow显示的变化。
所以,我们再来看看itemWindow是怎么样的
this._itemWindow = new Window_ItemList(0, wy, Graphics.boxWidth, wh);
itemWindow是Window_ItemList的新建
我们就去Window_ItemList看看是怎么写的


我们看到,这里是设定,类型的,也就是你选择道具,装备,重要道具,那个类型
Window_ItemList.prototype.setCategory = function(category) {
    if (this._category !== category) {
        this._category = category;
        this.refresh();
        this.resetScroll();
    }
};

//然后我们还看到,这里是判断这个道具是哪个类型的
Window_ItemList.prototype.includes = function(item) {
    switch (this._category) {
//类型选择是道具
    case 'item':
//判断ITEM是道具,道具类型是1
        return DataManager.isItem(item) && item.itypeId === 1;
//类型选择是武器
    case 'weapon':
//判断ITEM是武器
        return DataManager.isWeapon(item);
//类型选择是防具
    case 'armor':
//判断ITEM是防具
        return DataManager.isArmor(item);
//类型选择是重要道具
    case 'keyItem':
//判断ITEM是道具,道具类型是2
        return DataManager.isItem(item) && item.itypeId === 2;
//没有选择时
    default:
        return false;
    }
};

点评

有了!! 我改了你說的那一行, this._itemWindow.setCategory('item'); 放入之後就有了。 非常感謝您!!  发表于 2019-2-5 17:45
不存在这一行的function是定义函数的。this.currentSymbol()是当前选项的Handled名,也就是addCommand括号里的第2个位置写的  发表于 2019-2-5 01:33
請問function this.currentSymbol(); 那是什麼意思?  发表于 2019-2-4 23:28
這行我就看不懂了 QQ  发表于 2019-2-4 23:27
你先要给this._itemWindow.setCategory(this.currentSymbol());设定_category  发表于 2019-2-4 22:42
回复 支持 1 反对 0

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-5-3 17:56

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表