社区应用 最新帖子 精华区 社区服务 会员列表 统计排行 道具中心
主题 : 请教一套好的状态法术跟随思路...[45度战斗非真位移]
级别: 总版主
显示用户信息 
30  发表于: 2007-01-26   
= =居然会无效……原本设定的该被人物盖住的会被盖住吗?
我突然发现,我是一个很幸运的好人。老婆真好~

点我进入JQ(激情)教程范例收集!

级别: 总版主
显示用户信息 
31  发表于: 2007-01-26   
经过试验终于发现了元凶,果然那个循环动画是有一点区别的,你只要把
复制代码
  1. def update_loop_animation
  2.     frame_index = @_loop_animation_index
  3.     cell_data = @_loop_animation.frames[frame_index].cell_data
  4.     position = @_loop_animation.position
  5.     animation_set_sprites(@_loop_animation_sprites, cell_data, position)
  6.     for i in 0..15
  7.     @_loop_animation_sprites[i].z = 0
  8.     end
  9.     for timing in @_loop_animation.timings
  10.     if timing.frame == frame_index
  11.       animation_process_timing(timing, true)
  12.     end
  13.     end
  14.   end

加进去,所有循环动画就会被角色挡住了。
我突然发现,我是一个很幸运的好人。老婆真好~

点我进入JQ(激情)教程范例收集!

级别: ②入门
显示用户信息 
32  发表于: 2007-01-26   
引用
引用第31楼杀鸡四天王2007-01-26 02:21发表的:
经过试验终于发现了元凶,果然那个循环动画是有一点区别的,你只要把
[code]
def update_loop_animation
    frame_index = @_loop_animation_index
    cell_data = @_loop_animation.frames[frame_index].cell_data
.......

现在偶都乱了  脚本盲...

帮整理下,谢谢了
级别: 总版主
显示用户信息 
33  发表于: 2007-01-26   
这样应该没有问题了:
复制代码
  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.   for i in 0..15
  289.   @_loop_animation_sprites[i].z = 0
  290.   end
  291.   else
  292.   frame_index = @_loop_animation_index
  293.   cell_data = @_loop_animation.frames[frame_index].cell_data
  294.   position = @_loop_animation.position
  295.   animation_set_sprites(@_loop_animation_sprites, cell_data, position, rpwt = false)
  296.   for i in 0..15
  297.   @_loop_animation_sprites[i].z = 0
  298.   end
  299.   for timing in @_loop_animation.timings
  300.     if timing.frame == frame_index
  301.     animation_process_timing(timing, true)
  302.     end
  303.   end
  304.   end
  305. end
  306. def animation_set_sprites(sprites, cell_data, position, rpwt = false)
  307.   if rpwt != false
  308.   for i in 0..15
  309.     sprites[i].visible = false
  310.   end
  311.   return
  312.   end
  313. ###########################################################################
  314.   for i in 0..15
  315.   sprite = sprites[i]
  316.   pattern = cell_data[i, 0]
  317.   if sprite == nil or pattern == nil or pattern == -1
  318.     sprite.visible = false if sprite != nil
  319.     next
  320.   end
  321.   sprite.visible = true
  322.   sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
  323.   if position == 3
  324.     if self.viewport != nil
  325.     sprite.x = self.viewport.rect.width / 2
  326.     sprite.y = self.viewport.rect.height - 160
  327.     else
  328.     sprite.x = 320
  329.     sprite.y = 240
  330.     end
  331.   else
  332.     sprite.x = self.x - self.ox + self.src_rect.width / 2
  333.     sprite.y = self.y - self.oy + self.src_rect.height / 2
  334.     sprite.y -= self.src_rect.height / 4 if position == 0
  335.     sprite.y += self.src_rect.height / 4 if position == 2
  336.   end
  337.   sprite.x += cell_data[i, 1]
  338.   sprite.y += cell_data[i, 2]
  339. ###########################################################################
  340.   case @_animation.id
  341.   when 151 # 动画编号,自己设定
  342.     sprite.z = 5
  343.   when 1..150 # 其他的动画编号
  344.     sprite.z = 2000
  345.   end
  346. ###########################################################################
  347.   sprite.ox = 96
  348.   sprite.oy = 96
  349.   sprite.zoom_x = cell_data[i, 3] / 100.0
  350.   sprite.zoom_y = cell_data[i, 3] / 100.0
  351.   sprite.angle = cell_data[i, 4]
  352.   sprite.mirror = (cell_data[i, 5] == 1)
  353.   sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
  354.   sprite.blend_type = cell_data[i, 7]
  355.   end
  356. end
  357. def animation_process_timing(timing, hit)
  358.   if (timing.condition == 0) or
  359.     (timing.condition == 1 and hit == true) or
  360.     (timing.condition == 2 and hit == false)
  361.   if timing.se.name != ""
  362.     se = timing.se
  363.     Audio.se_play("Audio/SE/" + se.name, se.volume, se.pitch)
  364.   end
  365.   case timing.flash_scope
  366.   when 1
  367.     self.flash(timing.flash_color, timing.flash_duration * 2)
  368.   when 2
  369.     if self.viewport != nil
  370.     self.viewport.flash(timing.flash_color, timing.flash_duration * 2)
  371.     end
  372.   when 3
  373.     self.flash(nil, timing.flash_duration * 2)
  374.   end
  375.   end
  376. end
  377. def x=(x)
  378.   sx = x - self.x
  379.   if sx != 0
  380.   if @_animation_sprites != nil
  381.     for i in 0..15
  382.     @_animation_sprites[i].x += sx
  383.     end
  384.   end
  385.   if @_loop_animation_sprites != nil
  386.     for i in 0..15
  387.     @_loop_animation_sprites[i].x += sx
  388.     end
  389.   end
  390.   end
  391.   super
  392. end
  393. def y=(y)
  394.   sy = y - self.y
  395.   if sy != 0
  396.   if @_animation_sprites != nil
  397.     for i in 0..15
  398.     @_animation_sprites[i].y += sy
  399.     end
  400.   end
  401.   if @_loop_animation_sprites != nil
  402.     for i in 0..15
  403.     @_loop_animation_sprites[i].y += sy
  404.     end
  405.   end
  406.   end
  407.   super
  408. end
  409. end
  410. end
我突然发现,我是一个很幸运的好人。老婆真好~

点我进入JQ(激情)教程范例收集!

级别: ②入门
显示用户信息 
34  发表于: 2007-01-26   
高人啊 果然没问题了.不过造成了游戏鼠标点地跑起来卡卡的.键盘没事…难道因为太长?

看能否优化下
级别: ②入门
显示用户信息 
35  发表于: 2007-01-26   
还有我发现我跑出去攻击了,状态动画消失了,这个是不是你故意改的啊?我现在先不要这个效果了.先实现这个动画层问题就行了
级别: 总版主
显示用户信息 
36  发表于: 2007-01-26   
优化版,理论上不会有问题。
复制代码
  1. module RPG
  2. class Sprite < ::Sprite
  3. ###########################################################################
  4.   def update_loop_animation
  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)
  9.     for i in 0..15
  10.     @_loop_animation_sprites[i].z = 0
  11.     end
  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. ###########################################################################
  19.   def animation_set_sprites(sprites, cell_data, position)
  20.     for i in 0..15
  21.     sprite = sprites[i]
  22.     pattern = cell_data[i, 0]
  23.     if sprite == nil or pattern == nil or pattern == -1
  24.       sprite.visible = false if sprite != nil
  25.     next
  26.     end
  27.     sprite.visible = true
  28.     sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
  29.     if position == 3
  30.     if self.viewport != nil
  31.       sprite.x = self.viewport.rect.width / 2
  32.       sprite.y = self.viewport.rect.height - 160
  33.     else
  34.       sprite.x = 320
  35.       sprite.y = 240
  36.     end
  37.     else
  38.     sprite.x = self.x - self.ox + self.src_rect.width / 2
  39.     sprite.y = self.y - self.oy + self.src_rect.height / 2
  40.     sprite.y -= self.src_rect.height / 4 if position == 0
  41.     sprite.y += self.src_rect.height / 4 if position == 2
  42.     end
  43.     sprite.x += cell_data[i, 1]
  44.     sprite.y += cell_data[i, 2]
  45. ###########################################################################
  46.     case @_animation.id
  47.     when 151 # 动画编号,自己设定
  48.     sprite.z = 5
  49.     when 1..150 # 其他的动画编号
  50.     sprite.z = 2000
  51.     end
  52. ###########################################################################
  53.     sprite.ox = 96
  54.     sprite.oy = 96
  55.     sprite.zoom_x = cell_data[i, 3] / 100.0
  56.     sprite.zoom_y = cell_data[i, 3] / 100.0
  57.     sprite.angle = cell_data[i, 4]
  58.     sprite.mirror = (cell_data[i, 5] == 1)
  59.     sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
  60.     sprite.blend_type = cell_data[i, 7]
  61.     end
  62.   end
  63. end
  64. end
[ 此贴被杀鸡四天王在2007-01-26 16:13重新编辑 ]
我突然发现,我是一个很幸运的好人。老婆真好~

点我进入JQ(激情)教程范例收集!

级别: 总版主
显示用户信息 
37  发表于: 2007-01-26   
引用
引用第35楼颠倒的彩虹2007-01-26 16:00发表的:
还有我发现我跑出去攻击了,状态动画消失了,这个是不是你故意改的啊?我现在先不要这个效果了.先实现这个动画层问题就行了


=。=不要了啊,那我改回来。
我突然发现,我是一个很幸运的好人。老婆真好~

点我进入JQ(激情)教程范例收集!

级别: ②入门
显示用户信息 
38  发表于: 2007-01-26   
恩.反正你的那个临时去掉状态法术的范例我收藏了.

想要的化再加上,不过要使他消失的华丽点

你一定要把这个脚本弄到最简...不然鼠标跑起来会卡呢
级别: ②入门
显示用户信息 
39  发表于: 2007-01-26   
没问题了
描述
快速回复

认证码:

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