Project1

标题: 血槽问题 [打印本页]

作者: 果冻叮当猫    时间: 2009-12-17 19:53
标题: 血槽问题
HPSP代码如下
def HP(actor,x,y)
  
    @bitmap1 = Bitmap.new("Graphics/Pictures/HP1.png")
    @src_rect1 = Rect.new(0, 0, @bitmap1.width, @bitmap1.height)
    self.contents.blt(x, y, @bitmap1, @src_rect1)
   
    @bitmap2 = Bitmap.new("Graphics/Pictures/HP2.png")
    h1 = @bitmap2.height * actor.hp / actor.maxhp
    @src_rect2 = Rect.new(0, 0, @bitmap2.width, h1) #@bitmap2.height)
    self.contents.blt(x + 1, y + 1, @bitmap2, @src_rect2)

end
  
def SP(actor,x,y)
  
    @bitmap1 = Bitmap.new("Graphics/Pictures/SP1.png")
    @src_rect1 = Rect.new(0, 0, @bitmap1.width, @bitmap1.height)
    self.contents.blt(x, y, @bitmap1, @src_rect1)
   
    @bitmap2 = Bitmap.new("Graphics/Pictures/SP2.png")
    h2 = @bitmap2.height * actor.sp / actor.maxsp
    @src_rect2 = Rect.new(0, 0, @bitmap2.width, h2) #@bitmap2.height)
    self.contents.blt(x + 1, y + 1, @bitmap2, @src_rect2)

end  



请问哪位高手帮帮忙,问题如上
作者: 果冻叮当猫    时间: 2009-12-17 19:54
问题就是减血的时候都是反方向的,有没有办法处理成从上到下减血的方式(使用的是图片血条)
作者: 后知后觉    时间: 2009-12-17 20:51
本帖最后由 后知后觉 于 2009-12-17 21:00 编辑

这完全是一个数学问题
主要就是调整Y坐标
就是图片的总长度减去图片现在的显示长度就是y坐标应该要增加的长度
现在显示的长度就是那个 h1了

@src_rect2 = Rect.new(0, @bitmap2.height - h1, @bitmap2.width, h1)
self.contents.blt(x + 1, y + [email protected], @bitmap2, @src_rect2)




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