@Focker_c:
Cậu dùng hàm draw_icon() được định nghĩa trong class Window_Base này:
[php]
#
# * Draw Icon
# enabled : Enabled flag. When false, draw semi-transparently.
#
def draw_icon(icon_index, x, y, enabled = true)
bitmap = Cache.system("Iconset")
rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
contents.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
end
[/php]
Bây giờ chèn vào đoạn script ở trên sẽ thành:
[php]
class Window_Text < Window_Base
#
# * Object Initialization
#
def initialize(i_left, i_top, i_width, i_height)
super(i_left, i_top, i_width, i_height)
self.contents = Bitmap.new(width - 32, height - 32)
end
#
# * Draw text
#
def drawText(i_text, i_color, i_id_icon)
self.contents.clear
self.contents.font.color = text_color(i_color)
self.contents.draw_text(4, 0, 120, 32, i_text)
self.draw_icon(i_id_icon, 12, 32)
end
end
[/php]
Hoặc có thể dùng trực tiếp call script ở event:
[php]
$window = Window_Text.new()
$window.draw_icon(1, 4, 12)
[/php]
Nếu muốn vẽ item được định nghĩa trong database item thì dùng hàm: draw_item_name() cũng được định nghĩa trong class Window_Base
[php]
#
# * Draw Item Name
# enabled : Enabled flag. When false, draw semi-transparently.
#
def draw_item_name(item, x, y, enabled = true, width = 172)
return unless item
draw_icon(item.icon_index, x, y, enabled)
change_color(normal_color, enabled)
draw_text(x + 24, y, width, line_height, item.name)
end
[/php]
Ở trên vị trí vẽ mình fixed cứng, không sửa được nên cậu muốn sửa thì thêm tham số vào hàm nhé
Nhìn chung draw được nhiều cái lắm, cậu bật lên mà tham khảo :D
Comments
Cú pháp nó khác nhau thôi, chứ về bản chất là giống, anh từng dùng GML nên biết
THAM GIA GROUP CỦA TTC TRÊN FACEBOOK
Đây :
[php]class Window_Text < Window_Base
#
# * Object Initialization
#
def initialize(x, y)
super(x, y, 160, 64)
self.contents = Bitmap.new(width - 32, height - 32)
end
#
# * Draw text
#
def drawText(i_text, i_color)
self.contents.clear
self.contents.font.color = text_color(i_color)
self.contents.draw_text(4, 0, 120, 32, i_text)
self.contents.draw_icon(15, 0, 0,true)
end
end[/php]
Đã thêm
self.contents.draw_icon(15, 0, 0,true)
Why ?
def draw_icon là thây, no nằm trong windows_base
Ý của mình là mình có cái script này của @slucis7593 :
[php]class Window_Text < Window_Base
#
# * Object Initialization
#
def initialize
super(0, 0, 160, 64)
self.contents = Bitmap.new(width - 32, height - 32)
end
#
# * Draw text
#
def drawText(i_text, i_color)
self.contents.clear
self.contents.font.color = text_color(i_color)
self.contents.draw_text(4, 0, 120, 32, i_text)
end
end[/php]
Nhưng viết mã \i[icon_id] vào trong cái window này thì nó ko hiện icon. Giờ phải làm sao để vẽ đc icon ở trong cái window ấy ?
Cậu dùng hàm draw_icon() được định nghĩa trong class Window_Base này:
[php]
#
# * Draw Icon
# enabled : Enabled flag. When false, draw semi-transparently.
#
def draw_icon(icon_index, x, y, enabled = true)
bitmap = Cache.system("Iconset")
rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
contents.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
end
[/php]
Bây giờ chèn vào đoạn script ở trên sẽ thành:
[php]
class Window_Text < Window_Base
#
# * Object Initialization
#
def initialize(i_left, i_top, i_width, i_height)
super(i_left, i_top, i_width, i_height)
self.contents = Bitmap.new(width - 32, height - 32)
end
#
# * Draw text
#
def drawText(i_text, i_color, i_id_icon)
self.contents.clear
self.contents.font.color = text_color(i_color)
self.contents.draw_text(4, 0, 120, 32, i_text)
self.draw_icon(i_id_icon, 12, 32)
end
end
[/php]
Hoặc có thể dùng trực tiếp call script ở event:
[php]
$window = Window_Text.new()
$window.draw_icon(1, 4, 12)
[/php]
Nếu muốn vẽ item được định nghĩa trong database item thì dùng hàm: draw_item_name() cũng được định nghĩa trong class Window_Base
[php]
#
# * Draw Item Name
# enabled : Enabled flag. When false, draw semi-transparently.
#
def draw_item_name(item, x, y, enabled = true, width = 172)
return unless item
draw_icon(item.icon_index, x, y, enabled)
change_color(normal_color, enabled)
draw_text(x + 24, y, width, line_height, item.name)
end
[/php]
Ở trên vị trí vẽ mình fixed cứng, không sửa được nên cậu muốn sửa thì thêm tham số vào hàm nhé
Nhìn chung draw được nhiều cái lắm, cậu bật lên mà tham khảo :D
Tình hình là vẫn ko draw đc icon , @slucis7593 ơi .
Xài
[php]$window = Window_Text.new()
$window.draw_icon(1, 4, 12) [/php]
Cũng ko được mà cho cái script này vào xài cũng ko được :
[php]class Window_Text < Window_Base
#
# * Object Initialization
#
def initialize(i_left, i_top, i_width, i_height)
super(i_left, i_top, i_width, i_height)
self.contents = Bitmap.new(width - 32, height - 32)
end
#
# * Draw text
#
def drawText(i_text, i_color, i_id_icon)
self.contents.clear
self.contents.font.color = text_color(i_color)
self.contents.draw_text(4, 0, 120, 32, i_text)
self.draw_icon(i_id_icon, 12, 32)
end
end [/php]
haiz
:ngaytho:
-_- hiz, sao máy bác cứ khác khác vậy nhỉ, máy mình chạy ngon mà.
Mình dùng call script:
[php]
$wd = Window_Text.new(0, 0, 160, 100)
$wd.drawText("Hello", 0, 7)
$wd.draw_icon(5, 40, 30)
[/php]
Hiển thị được 2 cái icon thứ 7 và thứ 5 lên cửa sổ đây này:
Lỗi do script khác :D lại cứ tưởng là cái này lỗi :D
Fix rồi ^^
Ok ok ! Cảm ơn mọi người ^^
Lệnh toàn màn hình:
[php]
keybd = Win32API.new 'user32.dll', 'keybd_event', , 'v'
keybd.call(0xA4, 0, 0, 0) ; keybd.call(13, 0, 0, 0)
keybd.call(13, 0, 2, 0) ; keybd.call(0xA4, 0, 2, 0)
[/php]
Giải thích: lệnh này giả lập tổ hợp phím Alt+Enter để fullscreen