赞 | 68 |
VIP | 397 |
好人卡 | 580 |
积分 | 22 |
经验 | 311270 |
最后登录 | 2022-3-9 |
在线时间 | 4033 小时 |
Lv3.寻梦者 (版主) …あたしは天使なんかじゃないわ
- 梦石
- 0
- 星屑
- 2208
- 在线时间
- 4033 小时
- 注册时间
- 2010-10-4
- 帖子
- 10779
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 taroxd 于 2014-8-5 20:15 编辑
提问区回答问题写的。随手写的,所以写的结构很混乱。坐标什么的……懒得给你们设置了,自己调吧。反正都是变量= =
效果图:
@Cache
module Cache @cache ||= {} def self.ellipse(a, b, color) key = [:ellipse, a, b, color] unless include?(key) @cache[key] = bitmap = Bitmap.new(2 * a, 2 * b) 0.step(2*Math::PI, 0.01) do |theta| bitmap.set_pixel((a+a*Math.cos(theta)).to_i, (b+b*Math.sin(theta)).to_i, color) end end @cache[key] end end class Spriteset_Map alias cs_20140805 create_shadow def create_shadow cs_20140805 @ellipse_sprite = Sprite.new a, b, c = 50, 40, Color.new(255,0,0) @ellipse_sprite.bitmap = Cache.ellipse(a,b,c).clone @ellipse_sprite.bitmap.fill_rect(0, b, 2*a, 1, c) @mapinfo_sprite = Sprite.new @mapinfo_sprite.bitmap = Bitmap.new(2*a, 2*b) @mapinfo_sprite.bitmap.font.size = 16 @ellipse_sprite.x = 10 @ellipse_sprite.y = 10 @mapinfo_sprite.x = 10 @mapinfo_sprite.y = 10 end alias us_20140805 update_shadow def update_shadow us_20140805 if @mapinfo_to_draw != mapinfo_to_draw n, x, y = @mapinfo_to_draw = mapinfo_to_draw text = "X:#{x} Y:#{y}" b = @mapinfo_sprite.bitmap b.clear b.draw_text(0,20,b.width,20,n,1) b.draw_text(0,40,b.width,20,text,1) end end alias ds_20140805 dispose_shadow def dispose_shadow ds_20140805 @ellipse_sprite.bitmap.dispose @ellipse_sprite.dispose @mapinfo_sprite.bitmap.dispose @mapinfo_sprite.dispose end def mapinfo_to_draw [$game_map.display_name, $game_player.x, $game_player.y] end end
module Cache
@cache ||= {}
def self.ellipse(a, b, color)
key = [:ellipse, a, b, color]
unless include?(key)
@cache[key] = bitmap = Bitmap.new(2 * a, 2 * b)
0.step(2*Math::PI, 0.01) do |theta|
bitmap.set_pixel((a+a*Math.cos(theta)).to_i,
(b+b*Math.sin(theta)).to_i, color)
end
end
@cache[key]
end
end
class Spriteset_Map
alias cs_20140805 create_shadow
def create_shadow
cs_20140805
@ellipse_sprite = Sprite.new
a, b, c = 50, 40, Color.new(255,0,0)
@ellipse_sprite.bitmap = Cache.ellipse(a,b,c).clone
@ellipse_sprite.bitmap.fill_rect(0, b, 2*a, 1, c)
@mapinfo_sprite = Sprite.new
@mapinfo_sprite.bitmap = Bitmap.new(2*a, 2*b)
@mapinfo_sprite.bitmap.font.size = 16
@ellipse_sprite.x = 10
@ellipse_sprite.y = 10
@mapinfo_sprite.x = 10
@mapinfo_sprite.y = 10
end
alias us_20140805 update_shadow
def update_shadow
us_20140805
if @mapinfo_to_draw != mapinfo_to_draw
n, x, y = @mapinfo_to_draw = mapinfo_to_draw
text = "X:#{x} Y:#{y}"
b = @mapinfo_sprite.bitmap
b.clear
b.draw_text(0,20,b.width,20,n,1)
b.draw_text(0,40,b.width,20,text,1)
end
end
alias ds_20140805 dispose_shadow
def dispose_shadow
ds_20140805
@ellipse_sprite.bitmap.dispose
@ellipse_sprite.dispose
@mapinfo_sprite.bitmap.dispose
@mapinfo_sprite.dispose
end
def mapinfo_to_draw
[$game_map.display_name, $game_player.x, $game_player.y]
end
end
|
|