幻想森林

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 761|回复: 3

进来讨论下,这段代码阿?

[复制链接]

16

主题

46

帖子

1665

积分

⑥精研

积分
1665
发表于 2005-8-6 13:38:46 | 显示全部楼层 |阅读模式
class Sprite_Battler < Animated_Sprite

attr_accessor :battler
attr_reader   :index
attr_accessor :target_index
attr_accessor :frame_width

  
def initialize(viewport, battler = nil)
   super(viewport)
   @battler = battler
   @pattern_b = 0 #
   @counter_b = 0 #
   @index = 0     #
   if @battler != nil
     tempbitmap = RPG::Cache.battler(@battler.battler_name, @battler.battler_hue)
     @frame_width = tempbitmap.width/4
     picturephase = @battler.picturephase
     if picturephase == "66RPG"
       @frame_height = tempbitmap.height/8
     else
       @frame_height = tempbitmap.height/picturephase.to_i
     end     
   else
     @frame_width, @frame_height = 1,1
   end   
   # start sprite
   @battler.is_a?(Game_Enemy) ? enemy_pose(1) : pose(1)
   @battler_visible = false
   if $target_index == nil
     $target_index = 0
   end
end
  
def index=(index) #
   @index = index  #
   update          #
end               #
  
def dispose
   if self.bitmap != nil
     self.bitmap.dispose
   end
   super
end
  
def enemy                                             #
   $target_index += $game_troop.enemies.size
   $target_index %= $game_troop.enemies.size
   return $game_troop.enemies[$target_index]           #
end                                                   #
  
def actor                                             #
   $target_index += $game_party.actors.size
   $target_index %= $game_party.actors.size
   return $game_party.actors[$target_index]            #
end      

为什么红色@frame_height = tempbitmap.height/picturephase.to_i这个代码,,老是说我,
ZeroDivisionError divided by 0怎么改阿,我是从王者归来复刻2003超级横板战斗拿的代码



     
回复

使用道具 举报

carol3 该用户已被删除
发表于 2005-8-6 20:32:58 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

16

主题

46

帖子

1665

积分

⑥精研

积分
1665
 楼主| 发表于 2005-8-6 21:11:25 | 显示全部楼层
楼上的,,谁都知道,,除数不能除0的
我就是不是很明白,,到底,,要改,哪里??
请你指点下阿
回复 支持 反对

使用道具 举报

16

主题

46

帖子

1665

积分

⑥精研

积分
1665
 楼主| 发表于 2005-8-6 21:54:36 | 显示全部楼层
我如果,把后面的picturephase.to_i改成其他的数字,,效果就变了
picturephase.to_i这个什么意思??
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|幻想森林

GMT+8, 2025-6-23 01:18 , Processed in 0.010817 second(s), 21 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

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