Project1

标题: 请教个Bitmap的问题 [打印本页]

作者: 缺牙de兔子    时间: 2007-12-29 04:50
标题: 请教个Bitmap的问题
以下引用缺牙de兔子于2007-12-28 18:00:45的发言:

没完了--刷新失败

[本贴由作者于 2007-12-28 19:41:53 最后编辑]


  1. #######################################################################################################
  2. #
  3. #######################################################################################################
  4. class Zandou_My_Battle
  5.    
  6.   def main
  7.     judge($game_variables[76],$game_variables[77],$game_variables[78] ,
  8.     $game_variables[79],$game_variables[80],$game_variables[81],
  9.     $game_variables[82],$game_variables[83],$game_variables[84] )
  10.      # 清除战斗调用标志
  11.     $game_temp.battle_calling = false
  12.     # 清除菜单调用标志
  13.     $game_temp.menu_calling = false
  14.     $game_temp.menu_beep = false
  15.     # 生成遇敌计数
  16.     $game_player.make_encounter_count
  17.     # 记忆地图 BGM 、停止 BGM
  18.     $game_temp.map_bgm = $game_system.playing_bgm
  19.     $game_system.bgm_stop
  20.     # 演奏战斗开始 SE
  21.     $game_system.se_play($data_system.battle_start_se)
  22.     # 演奏战斗 BGM
  23.     $game_system.bgm_play($game_system.battle_bgm)
  24.     loop do
  25.       
  26.     self.init_addr
  27.    
  28.     end
  29.    
  30.   end
  31.   
  32.   def judge(actor_Id,actor_Hp,actor_Mp ,actor_Atk,actor_Def,actor_X,actor_Y,actor_Z,actor_Action )
  33.     @actor_Id = actor_Id
  34.     @actor_Hp = actor_Hp
  35.     @actor_Mp = actor_Mp
  36.     @actor_Atk = actor_Atk
  37.     @actor_Def = actor_Def
  38.     @actor_X = actor_X
  39.     @actor_Y = actor_Y
  40.     @actor_Z = actor_Z
  41.     @actor_Action = actor_Action
  42.    
  43.     #p  "角色ID:#{@actor_Id}"
  44.     #p  "角色HP:#{@actor_Hp}"
  45.     #p  "角色SP:#{@actor_Mp}"
  46.     #p  "角色攻击力:#{@actor_Atk}"
  47.     #p  "角色防御力:#{@actor_Def}"
  48.     #p  "角色X坐标:#{@actor_X}"
  49.     #p  "角色Y坐标:#{@actor_Y}"
  50.     #p  "角色Z坐标:#{@actor_Z}"
  51.     #p  "角色动作:#{@actor_Action}"
  52.   end
  53.   
  54.   def init_addr
  55.    if( $game_variables[81] < 0)
  56.      $game_variables[81] = 0
  57.    end
  58.    if($game_variables[81] > 19)
  59.      $game_variables[81] = 19
  60.    end
  61.    
  62.     @init_X = $game_variables[81]
  63.     @init_Y = $game_variables[82]
  64.     @init_Z = $game_variables[83]
  65.    
  66.    devil = Sprite.new
  67.    devil.x = @init_X *32
  68.    devil.y = @init_Y *32 - 80
  69.    devil.bitmap = Bitmap.new("Graphics/Pictures/按下右")



  70.   end
  71.   
  72. end


复制代码




如果我不在main循环 使用并行事件调用的话就变成这样了....
而且不用我写代码删除 图片就自己消失了--





[LINE]1,#dddddd[/LINE]版务信息:本贴由楼主自主结贴~
作者: 缺牙de兔子    时间: 2007-12-29 04:50
标题: 请教个Bitmap的问题
以下引用缺牙de兔子于2007-12-28 18:00:45的发言:

没完了--刷新失败

[本贴由作者于 2007-12-28 19:41:53 最后编辑]


  1. #######################################################################################################
  2. #
  3. #######################################################################################################
  4. class Zandou_My_Battle
  5.    
  6.   def main
  7.     judge($game_variables[76],$game_variables[77],$game_variables[78] ,
  8.     $game_variables[79],$game_variables[80],$game_variables[81],
  9.     $game_variables[82],$game_variables[83],$game_variables[84] )
  10.      # 清除战斗调用标志
  11.     $game_temp.battle_calling = false
  12.     # 清除菜单调用标志
  13.     $game_temp.menu_calling = false
  14.     $game_temp.menu_beep = false
  15.     # 生成遇敌计数
  16.     $game_player.make_encounter_count
  17.     # 记忆地图 BGM 、停止 BGM
  18.     $game_temp.map_bgm = $game_system.playing_bgm
  19.     $game_system.bgm_stop
  20.     # 演奏战斗开始 SE
  21.     $game_system.se_play($data_system.battle_start_se)
  22.     # 演奏战斗 BGM
  23.     $game_system.bgm_play($game_system.battle_bgm)
  24.     loop do
  25.       
  26.     self.init_addr
  27.    
  28.     end
  29.    
  30.   end
  31.   
  32.   def judge(actor_Id,actor_Hp,actor_Mp ,actor_Atk,actor_Def,actor_X,actor_Y,actor_Z,actor_Action )
  33.     @actor_Id = actor_Id
  34.     @actor_Hp = actor_Hp
  35.     @actor_Mp = actor_Mp
  36.     @actor_Atk = actor_Atk
  37.     @actor_Def = actor_Def
  38.     @actor_X = actor_X
  39.     @actor_Y = actor_Y
  40.     @actor_Z = actor_Z
  41.     @actor_Action = actor_Action
  42.    
  43.     #p  "角色ID:#{@actor_Id}"
  44.     #p  "角色HP:#{@actor_Hp}"
  45.     #p  "角色SP:#{@actor_Mp}"
  46.     #p  "角色攻击力:#{@actor_Atk}"
  47.     #p  "角色防御力:#{@actor_Def}"
  48.     #p  "角色X坐标:#{@actor_X}"
  49.     #p  "角色Y坐标:#{@actor_Y}"
  50.     #p  "角色Z坐标:#{@actor_Z}"
  51.     #p  "角色动作:#{@actor_Action}"
  52.   end
  53.   
  54.   def init_addr
  55.    if( $game_variables[81] < 0)
  56.      $game_variables[81] = 0
  57.    end
  58.    if($game_variables[81] > 19)
  59.      $game_variables[81] = 19
  60.    end
  61.    
  62.     @init_X = $game_variables[81]
  63.     @init_Y = $game_variables[82]
  64.     @init_Z = $game_variables[83]
  65.    
  66.    devil = Sprite.new
  67.    devil.x = @init_X *32
  68.    devil.y = @init_Y *32 - 80
  69.    devil.bitmap = Bitmap.new("Graphics/Pictures/按下右")



  70.   end
  71.   
  72. end


复制代码




如果我不在main循环 使用并行事件调用的话就变成这样了....
而且不用我写代码删除 图片就自己消失了--





[LINE]1,#dddddd[/LINE]版务信息:本贴由楼主自主结贴~
作者: 缺牙de兔子    时间: 2007-12-29 05:24
图片自动消失 问题出在哪呢?
作者: 美兽    时间: 2007-12-29 17:43
因为你存入的是局部变量,方法结束自然会被释放,把变量改实例或全局变量应该就可以了。
作者: 缺牙de兔子    时间: 2007-12-29 19:05
那全局变量怎么标识?
作者: tiwzyong    时间: 2007-12-29 20:21
提示: 作者被禁止或删除 内容自动屏蔽
作者: 缺牙de兔子    时间: 2007-12-29 21:13
还是不行......用全局还是会消失 --
我是在事件并行处理 做的
作者: link006007    时间: 2007-12-29 23:24
devil 是局部的,  函数 init_addr 每次被调用完, 它都随着栈一起释放 [LINE]1,#dddddd[/LINE]系统信息:本贴由楼主认可为正确答案,66RPG感谢您的热情解答~




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1