| 赞 | 659  | 
 
| VIP | 62 | 
 
| 好人卡 | 144 | 
 
| 积分 | 337 | 
 
| 经验 | 110435 | 
 
| 最后登录 | 2024-7-10 | 
 
| 在线时间 | 5096 小时 | 
 
 
 
 
 
Lv5.捕梦者 
	- 梦石
 - 0 
 
        - 星屑
 - 33742 
 
        - 在线时间
 - 5096 小时
 
        - 注册时间
 - 2012-11-19
 
        - 帖子
 - 4877
 
 
  
 
 | 
	
 本帖最后由 芯☆淡茹水 于 2015-5-1 20:26 编辑  
 
一个大体的思路:- ##以一般的鼠标脚本为例:
 
  
- #定义一个获取鼠标指向的敌人的方法。
 
 - def get_enemy
 
 -   #获取当前鼠标指向的坐标。
 
 -   x, y = Mouse.get_mouse_pos
 
 -   #循环敌人队伍。
 
 -   for enemy in $game_troop.enemies
 
 -     #跳过不存在的敌人。
 
 -     next unless enemy.exist?
 
 -     #获取敌人战斗位图。
 
 -     bitmap = RPG::Cache.battler(enemy.battler_name, enemy.battler_hue)
 
 -     #判断鼠标是否在敌人的战斗图片内。
 
 -     width = bitmap.width / 2
 
 -     height = bitmap.height
 
 -     if x > enemy.screen_x - width and x < enemy.screen_x + width and
 
 -      y > enemy.screen_y - height and y < enemy.screen_y
 
 -       #判断当前鼠标指向的图片点是否透明。
 
 -       b_x = x - enemy.screen_x + width
 
 -       b_y = y - enemy.screen_y + height
 
 -       #如果指向的图片点不透明,返回该 enemy 。
 
 -       if bitmap.get_pixel(b_x, b_y).alpha > 0
 
 -         return enemy
 
 -       end
 
 -     end
 
 -   end
 
 -   # 返回 nil 。
 
 -   return nil
 
 - end
 
  复制代码 在战斗中选择行动时,点击鼠标左键时,就这样判断是否指向敌人。 
如果不是 nil ,那么该角色的行动是普通攻击,攻击对象就是上面获取的 enemy 。 |   
 
 
 
 |