赞 | 7 |
VIP | 866 |
好人卡 | 185 |
积分 | 32 |
经验 | 130059 |
最后登录 | 2024-11-27 |
在线时间 | 3618 小时 |
Lv3.寻梦者 双子人
- 梦石
- 0
- 星屑
- 3190
- 在线时间
- 3618 小时
- 注册时间
- 2009-4-4
- 帖子
- 4154
|
这是我写的最离谱的脚本
为了实现激光的效果(自动瞄准离该“character”最近的事件,然后在屏幕中character和事件之间画出一条激光)
写完之后,发现有一些错误,于是就改成下面的样子。- class Game_Character
- def auto_laser
- @_laser_kill = nil
- @_laser_sprite = nil
- for distance in 1..13
-
- for event in $game_map.events.values
-
- for x in @x-distance..@x+distance
- for y in @y-distance..@y+distance
- if event.x == x and event.y == y# and die_in_auto_laser?(event.name)
-
- if event.x < @x
- laser_x = event.x * 32
- laser_width = (@x - event.x) * 32
- else
- laser_x = @x * 32
- laser_width = (event.x - @x) * 32
- end
- if event.y < @y
- laser_y = event.y * 32
- laser_height = (@y - event.y) * 32
- else
- laser_y = @y * 32
- laser_height = (event.y - @y) * 32
- end
- @_laser_sprite = Auto_Laser.new(laser_x, laser_y, laser_width, laser_height, @x, @y, event.x, event.y)
- @_laser_kill = event
- return
- end
- end
- end
- end
- end
- end
-
- def auto_laser_kill
- @_laser_sprite.dispose if @_laser_sprite != nil
- return if @_laser_kill == nil
- event = @_laser_kill
- event.animation_id = 108
- #event.drop_item
- event.erase
- end
-
-
- end
- #———————————————————————————————————————
- # Auto_Laser
- #———————————————————————————————————————
- class Auto_Laser < RPG::Sprite
-
- def initialize(x, y, width, height, laser_x, laser_y, event_x, event_y)
- super(Viewport.new(x, y, width, height))
- @bitmap = nil
- @bitmap = Bitmap.new(width,height)
-
- for xx in 1..width
- for yy in 1..height
-
- if (xx / yy).to_i == (width / height).to_i
- if (laser_x < event_x and laser_y < event_y) or (event_x < laser_x and event_y < laser_y)
- @bitmap.fill_rect(xx, yy-1,1,1, Color.new(255,255,255,255))
- @bitmap.fill_rect(xx, yy,1,1, Color.new(0,255,255,255))
- @bitmap.fill_rect(xx, yy+1,1,1, Color.new(0,255,255,255))
- else
- @bitmap.fill_rect(xx, height-yy-1,1,1, Color.new(255,255,255,255))
- @bitmap.fill_rect(xx, height-yy,1,1, Color.new(0,255,255,255))
- @bitmap.fill_rect(xx, height-yy+1,1,1, Color.new(0,255,255,255))
- end
- end
-
- end
- end
- end
- def dispose
- @bitmap.dispose
- @bitmap = nil
- super
- end
- end
复制代码 经测试,会有随机以下两种情况:
1、事件的动画及消失均正常,但是却看不到激光。
2、@bitmap = Bitmap.new(width,height)出错,错误信息为无法创建bitmap。
但是我不知道从哪个突破点改了。求助一下。 |
评分
-
查看全部评分
|