社区应用 最新帖子 精华区 社区服务 会员列表 统计排行 道具中心
主题 : 请教一套好的状态法术跟随思路...[45度战斗非真位移]
级别: 总版主
显示用户信息 
10  发表于: 2007-01-25   
是谁压住了谁?状态压住了角色?还是角色压住了状态?理论上使用状态法了以后,角色自身的行走图就看不见了才对。
我的Blog:http://hi.baidu.com/bunnygod


RM2K->玩具。
RMXP->给人“会编程”感觉的玩具,当然实际上还不会编程。
(\__/)
("=.=) W
( ~  )~|
级别: ②入门
显示用户信息 
11  发表于: 2007-01-25   
还是按你说的,我就感觉状态法和主动法术的定义不一样,因为状态法是一个一直的循环动画

级别: 总版主
显示用户信息 
12  发表于: 2007-01-25   
直接把这段加在我之前给你的那个Module脚本里面:
复制代码
  1. def update_loop_animation
  2.     if @_animation_duration > 0
  3.     frame_index = @_loop_animation_index
  4.     cell_data = @_loop_animation.frames[frame_index].cell_data
  5.     position = @_loop_animation.position
  6.     animation_set_sprites(@_loop_animation_sprites, cell_data, position, rpwt = true)
  7.     else
  8.     frame_index = @_loop_animation_index
  9.     cell_data = @_loop_animation.frames[frame_index].cell_data
  10.     position = @_loop_animation.position
  11.     animation_set_sprites(@_loop_animation_sprites, cell_data, position, rpwt = false)
  12.     for timing in @_loop_animation.timings
  13.       if timing.frame == frame_index
  14.         animation_process_timing(timing, true)
  15.       end
  16.     end
  17.     end
  18.   end
  19.   def animation_set_sprites(sprites, cell_data, position, rpwt = false)
  20.     if rpwt != false
  21.     for i in 0..15
  22.       sprites[i].visible = false
  23.     end
  24.     return
  25.     end

因为我发现我刚才给你的那个范例和之前教给你的方法定义了相同的地方,会不会是互相覆盖导致的。。。理论上来说,循环动画也是和普通动画用了一样的生成机理,不应该出问题啊。。。
我的Blog:http://hi.baidu.com/bunnygod


RM2K->玩具。
RMXP->给人“会编程”感觉的玩具,当然实际上还不会编程。
(\__/)
("=.=) W
( ~  )~|
级别: ②入门
显示用户信息 
13  发表于: 2007-01-25   
加到那个里面的那个位置...加错了游戏会运行错误..
级别: 总版主
显示用户信息 
14  发表于: 2007-01-25   
可能是位置的问题。

发一个完整的:
复制代码
  1. module RPG
  2. class Sprite < ::Sprite
  3. def update_loop_animation
  4.   if @_animation_duration > 0
  5.   frame_index = @_loop_animation_index
  6.   cell_data = @_loop_animation.frames[frame_index].cell_data
  7.   position = @_loop_animation.position
  8.   animation_set_sprites(@_loop_animation_sprites, cell_data, position, rpwt = true)
  9.   else
  10.   frame_index = @_loop_animation_index
  11.   cell_data = @_loop_animation.frames[frame_index].cell_data
  12.   position = @_loop_animation.position
  13.   animation_set_sprites(@_loop_animation_sprites, cell_data, position, rpwt = false)
  14.   for timing in @_loop_animation.timings
  15.     if timing.frame == frame_index
  16.     animation_process_timing(timing, true)
  17.     end
  18.   end
  19.   end
  20. end
  21. def animation_set_sprites(sprites, cell_data, position, rpwt = false)
  22.   if rpwt != false
  23.   for i in 0..15
  24.     sprites[i].visible = false
  25.   end
  26.   return
  27.   end
  28.   sprite.visible = true
  29.   sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
  30.   if position == 3
  31.     if self.viewport != nil
  32.     sprite.x = self.viewport.rect.width / 2
  33.     sprite.y = self.viewport.rect.height - 160
  34.     else
  35.     sprite.x = 320
  36.     sprite.y = 240
  37.     end
  38.   else
  39.     sprite.x = self.x - self.ox + self.src_rect.width / 2
  40.     sprite.y = self.y - self.oy + self.src_rect.height / 2
  41.     sprite.y -= self.src_rect.height / 4 if position == 0
  42.     sprite.y += self.src_rect.height / 4 if position == 2
  43.   end
  44.   sprite.x += cell_data[i, 1]
  45.   sprite.y += cell_data[i, 2]
  46. ###########################################################################
  47.   case @_animation.id
  48.   when 103..106, 108..119, 121..124 #动画编号,自己设定
  49.     sprite.z = @battler.screen_z
  50.   when 1..102, 107, 120, 125..131 #其他的动画编号
  51.     sprite.z = 2000
  52.   end
  53. ###########################################################################
  54.   sprite.ox = 96
  55.   sprite.oy = 96
  56.   sprite.zoom_x = cell_data[i, 3] / 100.0
  57.   sprite.zoom_y = cell_data[i, 3] / 100.0
  58.   sprite.angle = cell_data[i, 4]
  59.   sprite.mirror = (cell_data[i, 5] == 1)
  60.   sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
  61.   sprite.blend_type = cell_data[i, 7]
  62.   end
  63. end
  64. end
  65. end
[ 此贴被好人卡的神话在2007-01-25 19:01重新编辑 ]
我的Blog:http://hi.baidu.com/bunnygod


RM2K->玩具。
RMXP->给人“会编程”感觉的玩具,当然实际上还不会编程。
(\__/)
("=.=) W
( ~  )~|
级别: ②入门
显示用户信息 
15  发表于: 2007-01-25   
脚本报错
74行发生了SyntaxError
级别: 总版主
显示用户信息 
16  发表于: 2007-01-25   
写错东西了,更改了一下。。。
我的Blog:http://hi.baidu.com/bunnygod


RM2K->玩具。
RMXP->给人“会编程”感觉的玩具,当然实际上还不会编程。
(\__/)
("=.=) W
( ~  )~|
级别: ②入门
显示用户信息 
17  发表于: 2007-01-25   
怎么还是报同样的错误呢
级别: 总版主
显示用户信息 
18  发表于: 2007-01-25   
O O。。。难道是我RPWT。。。?直接用这个替换整个吧(注意你之前自己改过的不同层次的动画的地方换上你自己的)。
复制代码
  1. module RPG
  2. class Sprite < ::Sprite
  3.   @@_animations = []
  4.   @@_reference_count = {}
  5.   def initialize(viewport = nil)
  6.     super(viewport)
  7.     @_whiten_duration = 0
  8.     @_appear_duration = 0
  9.     @_escape_duration = 0
  10.     @_collapse_duration = 0
  11.     @_damage_duration = 0
  12.     @_animation_duration = 0
  13.     @_blink = false
  14.   end
  15.   def dispose
  16.     dispose_damage
  17.     dispose_animation
  18.     dispose_loop_animation
  19.     super
  20.   end
  21.   def whiten
  22.     self.blend_type = 0
  23.     self.color.set(255, 255, 255, 128)
  24.     self.opacity = 255
  25.     @_whiten_duration = 16
  26.     @_appear_duration = 0
  27.     @_escape_duration = 0
  28.     @_collapse_duration = 0
  29.   end
  30.   def appear
  31.     self.blend_type = 0
  32.     self.color.set(0, 0, 0, 0)
  33.     self.opacity = 0
  34.     @_appear_duration = 16
  35.     @_whiten_duration = 0
  36.     @_escape_duration = 0
  37.     @_collapse_duration = 0
  38.   end
  39.   def escape
  40.     self.blend_type = 0
  41.     self.color.set(0, 0, 0, 0)
  42.     self.opacity = 255
  43.     @_escape_duration = 32
  44.     @_whiten_duration = 0
  45.     @_appear_duration = 0
  46.     @_collapse_duration = 0
  47.   end
  48.   def collapse
  49.     self.blend_type = 1
  50.     self.color.set(255, 64, 64, 255)
  51.     self.opacity = 255
  52.     @_collapse_duration = 48
  53.     @_whiten_duration = 0
  54.     @_appear_duration = 0
  55.     @_escape_duration = 0
  56.   end
  57.   def damage(value, critical)
  58.     dispose_damage
  59.     if value.is_a?(Numeric)
  60.     damage_string = value.abs.to_s
  61.     else
  62.     damage_string = value.to_s
  63.     end
  64.     bitmap = Bitmap.new(160, 48)
  65.     bitmap.font.name = "Arial Black"
  66.     bitmap.font.size = 32
  67.     bitmap.font.color.set(0, 0, 0)
  68.     bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
  69.     bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
  70.     bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
  71.     bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
  72.     if value.is_a?(Numeric) and value < 0
  73.     bitmap.font.color.set(176, 255, 144)
  74.     else
  75.     bitmap.font.color.set(255, 255, 255)
  76.     end
  77.     bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
  78.     if critical
  79.     bitmap.font.size = 20
  80.     bitmap.font.color.set(0, 0, 0)
  81.     bitmap.draw_text(-1, -1, 160, 20, "CRITICAL", 1)
  82.     bitmap.draw_text(+1, -1, 160, 20, "CRITICAL", 1)
  83.     bitmap.draw_text(-1, +1, 160, 20, "CRITICAL", 1)
  84.     bitmap.draw_text(+1, +1, 160, 20, "CRITICAL", 1)
  85.     bitmap.font.color.set(255, 255, 255)
  86.     bitmap.draw_text(0, 0, 160, 20, "CRITICAL", 1)
  87.     end
  88.     @_damage_sprite = ::Sprite.new(self.viewport)
  89.     @_damage_sprite.bitmap = bitmap
  90.     @_damage_sprite.ox = 80
  91.     @_damage_sprite.oy = 20
  92.     @_damage_sprite.x = self.x
  93.     @_damage_sprite.y = self.y - self.oy / 2
  94.     @_damage_sprite.z = 3000
  95.     @_damage_duration = 40
  96.   end
  97.   def animation(animation, hit)
  98.     dispose_animation
  99.     @_animation = animation
  100.     return if @_animation == nil
  101.     @_animation_hit = hit
  102.     @_animation_duration = @_animation.frame_max
  103.     animation_name = @_animation.animation_name
  104.     animation_hue = @_animation.animation_hue
  105.     bitmap = RPG::Cache.animation(animation_name, animation_hue)
  106.     if @@_reference_count.include?(bitmap)
  107.     @@_reference_count[bitmap] += 1
  108.     else
  109.     @@_reference_count[bitmap] = 1
  110.     end
  111.     @_animation_sprites = []
  112.     if @_animation.position != 3 or not @@_animations.include?(animation)
  113.     for i in 0..15
  114.       sprite = ::Sprite.new(self.viewport)
  115.       sprite.bitmap = bitmap
  116.       sprite.visible = false
  117.       @_animation_sprites.push(sprite)
  118.     end
  119.     unless @@_animations.include?(animation)
  120.       @@_animations.push(animation)
  121.     end
  122.     end
  123.     update_animation
  124.   end
  125.   def loop_animation(animation)
  126.     return if animation == @_loop_animation
  127.     dispose_loop_animation
  128.     @_loop_animation = animation
  129.     return if @_loop_animation == nil
  130.     @_loop_animation_index = 0
  131.     animation_name = @_loop_animation.animation_name
  132.     animation_hue = @_loop_animation.animation_hue
  133.     bitmap = RPG::Cache.animation(animation_name, animation_hue)
  134.     if @@_reference_count.include?(bitmap)
  135.     @@_reference_count[bitmap] += 1
  136.     else
  137.     @@_reference_count[bitmap] = 1
  138.     end
  139.     @_loop_animation_sprites = []
  140.     for i in 0..15
  141.     sprite = ::Sprite.new(self.viewport)
  142.     sprite.bitmap = bitmap
  143.     sprite.visible = false
  144.     @_loop_animation_sprites.push(sprite)
  145.     end
  146.     update_loop_animation
  147.   end
  148.   def dispose_damage
  149.     if @_damage_sprite != nil
  150.     @_damage_sprite.bitmap.dispose
  151.     @_damage_sprite.dispose
  152.     @_damage_sprite = nil
  153.     @_damage_duration = 0
  154.     end
  155.   end
  156.   def dispose_animation
  157.     if @_animation_sprites != nil
  158.     sprite = @_animation_sprites[0]
  159.     if sprite != nil
  160.       @@_reference_count[sprite.bitmap] -= 1
  161.       if @@_reference_count[sprite.bitmap] == 0
  162.         sprite.bitmap.dispose
  163.       end
  164.     end
  165.     for sprite in @_animation_sprites
  166.       sprite.dispose
  167.     end
  168.     @_animation_sprites = nil
  169.     @_animation = nil
  170.     end
  171.   end
  172.   def dispose_loop_animation
  173.     if @_loop_animation_sprites != nil
  174.     sprite = @_loop_animation_sprites[0]
  175.     if sprite != nil
  176.       @@_reference_count[sprite.bitmap] -= 1
  177.       if @@_reference_count[sprite.bitmap] == 0
  178.         sprite.bitmap.dispose
  179.       end
  180.     end
  181.     for sprite in @_loop_animation_sprites
  182.       sprite.dispose
  183.     end
  184.     @_loop_animation_sprites = nil
  185.     @_loop_animation = nil
  186.     end
  187.   end
  188.   def blink_on
  189.     unless @_blink
  190.     @_blink = true
  191.     @_blink_count = 0
  192.     end
  193.   end
  194.   def blink_off
  195.     if @_blink
  196.     @_blink = false
  197.     self.color.set(0, 0, 0, 0)
  198.     end
  199.   end
  200.   def blink?
  201.     @_blink
  202.   end
  203.   def effect?
  204.     @_whiten_duration > 0 or
  205.     @_appear_duration > 0 or
  206.     @_escape_duration > 0 or
  207.     @_collapse_duration > 0 or
  208.     @_damage_duration > 0 or
  209.     @_animation_duration > 0
  210.   end
  211.   def update
  212.     super
  213.     if @_whiten_duration > 0
  214.     @_whiten_duration -= 1
  215.     self.color.alpha = 128 - (16 - @_whiten_duration) * 10
  216.     end
  217.     if @_appear_duration > 0
  218.     @_appear_duration -= 1
  219.     self.opacity = (16 - @_appear_duration) * 16
  220.     end
  221.     if @_escape_duration > 0
  222.     @_escape_duration -= 1
  223.     self.opacity = 256 - (32 - @_escape_duration) * 10
  224.     end
  225.     if @_collapse_duration > 0
  226.     @_collapse_duration -= 1
  227.     self.opacity = 256 - (48 - @_collapse_duration) * 6
  228.     end
  229.     if @_damage_duration > 0
  230.     @_damage_duration -= 1
  231.     case @_damage_duration
  232.     when 38..39
  233.       @_damage_sprite.y -= 4
  234.     when 36..37
  235.       @_damage_sprite.y -= 2
  236.     when 34..35
  237.       @_damage_sprite.y += 2
  238.     when 28..33
  239.       @_damage_sprite.y += 4
  240.     end
  241.     @_damage_sprite.opacity = 256 - (12 - @_damage_duration) * 32
  242.     if @_damage_duration == 0
  243.       dispose_damage
  244.     end
  245.     end
  246.     if @_animation != nil and (Graphics.frame_count % 2 == 0)
  247.     @_animation_duration -= 1
  248.     update_animation
  249.     end
  250.     if @_loop_animation != nil and (Graphics.frame_count % 2 == 0)
  251.     update_loop_animation
  252.     @_loop_animation_index += 1
  253.     @_loop_animation_index %= @_loop_animation.frame_max
  254.     end
  255.     if @_blink
  256.     @_blink_count = (@_blink_count + 1) % 32
  257.     if @_blink_count < 16
  258.       alpha = (16 - @_blink_count) * 6
  259.     else
  260.       alpha = (@_blink_count - 16) * 6
  261.     end
  262.     self.color.set(255, 255, 255, alpha)
  263.     end
  264.     @@_animations.clear
  265.   end
  266.   def update_animation
  267.     if @_animation_duration > 0
  268.     frame_index = @_animation.frame_max - @_animation_duration
  269.     cell_data = @_animation.frames[frame_index].cell_data
  270.     position = @_animation.position
  271.     animation_set_sprites(@_animation_sprites, cell_data, position)
  272.     for timing in @_animation.timings
  273.       if timing.frame == frame_index
  274.         animation_process_timing(timing, @_animation_hit)
  275.       end
  276.     end
  277.     else
  278.     dispose_animation
  279.     end
  280.   end
  281. ###########################################################################
  282.   def update_loop_animation
  283.     if @_animation_duration > 0
  284.     frame_index = @_loop_animation_index
  285.     cell_data = @_loop_animation.frames[frame_index].cell_data
  286.     position = @_loop_animation.position
  287.     animation_set_sprites(@_loop_animation_sprites, cell_data, position, rpwt = true)
  288.     else
  289.     frame_index = @_loop_animation_index
  290.     cell_data = @_loop_animation.frames[frame_index].cell_data
  291.     position = @_loop_animation.position
  292.     animation_set_sprites(@_loop_animation_sprites, cell_data, position, rpwt = false)
  293.     for timing in @_loop_animation.timings
  294.       if timing.frame == frame_index
  295.         animation_process_timing(timing, true)
  296.       end
  297.     end
  298.     end
  299.   end
  300.   def animation_set_sprites(sprites, cell_data, position, rpwt = false)
  301.     if rpwt != false
  302.     for i in 0..15
  303.       sprites[i].visible = false
  304.     end
  305.     return
  306.     end
  307. ###########################################################################
  308.     for i in 0..15
  309.     sprite = sprites[i]
  310.     pattern = cell_data[i, 0]
  311.     if sprite == nil or pattern == nil or pattern == -1
  312.       sprite.visible = false if sprite != nil
  313.       next
  314.     end
  315.     sprite.visible = true
  316.     sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
  317.     if position == 3
  318.       if self.viewport != nil
  319.         sprite.x = self.viewport.rect.width / 2
  320.         sprite.y = self.viewport.rect.height - 160
  321.       else
  322.         sprite.x = 320
  323.         sprite.y = 240
  324.       end
  325.     else
  326.       sprite.x = self.x - self.ox + self.src_rect.width / 2
  327.       sprite.y = self.y - self.oy + self.src_rect.height / 2
  328.       sprite.y -= self.src_rect.height / 4 if position == 0
  329.       sprite.y += self.src_rect.height / 4 if position == 2
  330.     end
  331.     sprite.x += cell_data[i, 1]
  332.     sprite.y += cell_data[i, 2]
  333. ###########################################################################
  334.     case @_animation.id
  335.     when 103..106, 108..119, 121..124 #动画编号,自己设定
  336.       sprite.z = @battler.screen_z
  337.     when 1..102, 107, 120, 125..131 #其他的动画编号
  338.       sprite.z = 2000
  339.     end
  340. ###########################################################################
  341.     sprite.ox = 96
  342.     sprite.oy = 96
  343.     sprite.zoom_x = cell_data[i, 3] / 100.0
  344.     sprite.zoom_y = cell_data[i, 3] / 100.0
  345.     sprite.angle = cell_data[i, 4]
  346.     sprite.mirror = (cell_data[i, 5] == 1)
  347.     sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
  348.     sprite.blend_type = cell_data[i, 7]
  349.     end
  350.   end
  351.   def animation_process_timing(timing, hit)
  352.     if (timing.condition == 0) or
  353.       (timing.condition == 1 and hit == true) or
  354.       (timing.condition == 2 and hit == false)
  355.     if timing.se.name != ""
  356.       se = timing.se
  357.       Audio.se_play("Audio/SE/" + se.name, se.volume, se.pitch)
  358.     end
  359.     case timing.flash_scope
  360.     when 1
  361.       self.flash(timing.flash_color, timing.flash_duration * 2)
  362.     when 2
  363.       if self.viewport != nil
  364.         self.viewport.flash(timing.flash_color, timing.flash_duration * 2)
  365.       end
  366.     when 3
  367.       self.flash(nil, timing.flash_duration * 2)
  368.     end
  369.     end
  370.   end
  371.   def x=(x)
  372.     sx = x - self.x
  373.     if sx != 0
  374.     if @_animation_sprites != nil
  375.       for i in 0..15
  376.         @_animation_sprites[i].x += sx
  377.       end
  378.     end
  379.     if @_loop_animation_sprites != nil
  380.       for i in 0..15
  381.         @_loop_animation_sprites[i].x += sx
  382.       end
  383.     end
  384.     end
  385.     super
  386.   end
  387.   def y=(y)
  388.     sy = y - self.y
  389.     if sy != 0
  390.     if @_animation_sprites != nil
  391.       for i in 0..15
  392.         @_animation_sprites[i].y += sy
  393.       end
  394.     end
  395.     if @_loop_animation_sprites != nil
  396.       for i in 0..15
  397.         @_loop_animation_sprites[i].y += sy
  398.       end
  399.     end
  400.     end
  401.     super
  402.   end
  403. end
  404. end
我的Blog:http://hi.baidu.com/bunnygod


RM2K->玩具。
RMXP->给人“会编程”感觉的玩具,当然实际上还不会编程。
(\__/)
("=.=) W
( ~  )~|
级别: ②入门
显示用户信息 
19  发表于: 2007-01-25   
这次不报错了,不过貌似没有一点变化..


 另 发现游戏爆卡...
描述
快速回复

认证码:

验证问题:
22-5=?,答案:17 正确答案:17
按"Ctrl+Enter"直接提交