Project1

标题: PIa一段脚本 [打印本页]

作者: yangff    时间: 2011-4-22 20:04
标题: PIa一段脚本
  1. class ZSprite<Sprite
  2.   def x=(v)
  3.     super(v)
  4.     @fucking=false if @fucking.nil?
  5.     if not @fucking
  6.       @real_x=v
  7.     end
  8.   end
  9.   def y=(v)
  10.     super(v)
  11.     @fucking=false if @fucking.nil?
  12.     if not @fucking
  13.       @real_y=v
  14.     end
  15.   end
  16.   def x
  17.     if @real_x.nil?
  18.       super
  19.     else
  20.       return @real_x
  21.     end
  22.   end
  23.   def y
  24.     if @real_y.nil?
  25.       super
  26.     else
  27.       return @real_y
  28.     end
  29.   end
  30.   def set_pos(xp,yp)
  31.     @fucking=true
  32.     self.x=xp
  33.     self.y=yp
  34.     @fucking=false
  35.   end
  36. end
  37.    
  38. class ZoomSprite
  39.   attr_accessor:sprites
  40.   attr_accessor:rect
  41.   def initialize(x,y,z,w,h)
  42.     @x,@y,@w,@h=x,y,w,h
  43.     @v=Viewport.new(x,y,w,h)
  44.     @v.z=z
  45.    
  46.   end
  47.   def update
  48.    
  49.     if @orect.nil? or @osprites.nil? or (@rect!=@orect) or (@sprites!=@osprites)
  50.       @osprites=@sprites
  51.       @orect=@rect
  52.       [email protected]_f/@rect.width.to_f
  53.       [email protected]_f/@rect.height.to_f
  54.       #p "hi"
  55.       for i in @sprites
  56.         i.viewport=@v
  57.         i.zoom_x=zx
  58.         i.zoom_y=zy
  59.         #p zx
  60.         i.set_pos(([email protected]),([email protected]))
  61.       end
  62.     end
  63.   end
  64. end
复制代码
使用方法
  1. zs=ZoomSprite.new(32,32,10000,100,100)
  2. zs.rect=Rect.new(0,0,100,100)
  3. t=ZSprite.new
  4. #p Datas.list["Pictures"]
  5. t.bitmap = Cache._load(Datas.list["Pictures"]["test.PNG"])
  6. t.x=0
  7. t.y=0

  8. t1=ZSprite.new
  9. #p Datas.list["Pictures"]
  10. t1.bitmap = Cache._load(Datas.list["Pictures"]["test.PNG"])
  11. t1.x=32
  12. t1.y=32


  13. zs.sprites=[t,t1]
  14. zs.update
  15. now=[0.00,0.00,100.00,100.00]
  16. from=Rect.new(0,0,100,100)
  17. tos=Rect.new(32,32,50,50)
  18. time=200
  19. @s=Sprite.new
  20. @s.bitmap=Bitmap.new(100,32)
  21. Graphics.wait(60)
  22. while true
  23.   Graphics.update
  24.   if time>0
  25.   now[0]+=(tos.x-now[0]).to_f/time.to_f
  26.   now[1]+=(tos.y-now[1]).to_f/time.to_f
  27.   now[2]+=(tos.width-now[2]).to_f/time.to_f
  28.   now[3]+=(tos.height-now[3]).to_f/time.to_f
  29.   time-=1
  30.   end
  31.   #zs.rect.x,zs.rect.y,zs.rect.width,zs.rect.height=now
  32.   zs.rect=Rect.new(*now)
  33.   @s.bitmap.clear
  34.   @s.bitmap.draw_text(0,0,100,32,now.to_s)
  35.   zs.update
  36. end
复制代码
相信没几个人用的到
作者: 蕾米莉亚·斯卡雷特    时间: 2011-4-22 20:52
说说结果是啥吧~~~
作者: yangff    时间: 2011-4-22 21:17
蕾米莉亚·斯卡雷特 发表于 2011-4-22 20:52
说说结果是啥吧~~~

就是可以把多个Sprite同时放大什么的……放大的效果像FXT那样的= =
作者: 蕾米莉亚·斯卡雷特    时间: 2011-4-22 21:39
没明白~~~




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