Project1
标题:
PIa一段脚本
[打印本页]
作者:
yangff
时间:
2011-4-22 20:04
标题:
PIa一段脚本
class ZSprite<Sprite
def x=(v)
super(v)
@fucking=false if @fucking.nil?
if not @fucking
@real_x=v
end
end
def y=(v)
super(v)
@fucking=false if @fucking.nil?
if not @fucking
@real_y=v
end
end
def x
if @real_x.nil?
super
else
return @real_x
end
end
def y
if @real_y.nil?
super
else
return @real_y
end
end
def set_pos(xp,yp)
@fucking=true
self.x=xp
self.y=yp
@fucking=false
end
end
class ZoomSprite
attr_accessor:sprites
attr_accessor:rect
def initialize(x,y,z,w,h)
@x,@y,@w,@h=x,y,w,h
@v=Viewport.new(x,y,w,h)
@v.z=z
end
def update
if @orect.nil? or @osprites.nil? or (@rect!=@orect) or (@sprites!=@osprites)
@osprites=@sprites
@orect=@rect
[email protected]
_f/@rect.width.to_f
[email protected]
_f/@rect.height.to_f
#p "hi"
for i in @sprites
i.viewport=@v
i.zoom_x=zx
i.zoom_y=zy
#p zx
i.set_pos((
[email protected]
),(
[email protected]
))
end
end
end
end
复制代码
使用方法
zs=ZoomSprite.new(32,32,10000,100,100)
zs.rect=Rect.new(0,0,100,100)
t=ZSprite.new
#p Datas.list["Pictures"]
t.bitmap = Cache._load(Datas.list["Pictures"]["test.PNG"])
t.x=0
t.y=0
t1=ZSprite.new
#p Datas.list["Pictures"]
t1.bitmap = Cache._load(Datas.list["Pictures"]["test.PNG"])
t1.x=32
t1.y=32
zs.sprites=[t,t1]
zs.update
now=[0.00,0.00,100.00,100.00]
from=Rect.new(0,0,100,100)
tos=Rect.new(32,32,50,50)
time=200
@s=Sprite.new
@s.bitmap=Bitmap.new(100,32)
Graphics.wait(60)
while true
Graphics.update
if time>0
now[0]+=(tos.x-now[0]).to_f/time.to_f
now[1]+=(tos.y-now[1]).to_f/time.to_f
now[2]+=(tos.width-now[2]).to_f/time.to_f
now[3]+=(tos.height-now[3]).to_f/time.to_f
time-=1
end
#zs.rect.x,zs.rect.y,zs.rect.width,zs.rect.height=now
zs.rect=Rect.new(*now)
@s.bitmap.clear
@s.bitmap.draw_text(0,0,100,32,now.to_s)
zs.update
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