2011-3-21 19:32
tranpol
【同步梦境插件】1.03
可以一边对话一边同步刷背景层的图片
效果为在设定的范围内糊来糊去= =
有梦境的感觉= =
===
[code];同步梦境插件 BY:TRANPOL 20110320.1.03
@if exp="typeof(global.dream_object) == 'undefined'"
@iscript
class dreamGrain
{
// 梦
var x;
var y;
var nbx;
var nby;
var s;
var l;
var w;
var h;
var dreams;
var timer;
var file;
var nbnb;
function dreamGrain(x,y,s,l,file,w,h)
{
// dream
this.x=x;
this.y=y;
this.s=s;
this.l=l;
this.file=file;
this.w=w;
this.h=h;
nbx=intrandom(s, l) if nbx==void;
nby=intrandom(s, l) if nby==void;
}
function finalize()
{
return true;
}
function spawn()
{
// 出現
kag.back.base.loadImages(%['storage'=>file,left:0,top:0,visible:true]);
kag.back.base.doBoxBlur(x,y);
kag.fore.base.operateRect(0, 0, kag.back.base, 0, 0, w, h);
}
function resetVisibleState()
{
return true;
}
function move()
{
// 开始糊来糊去= =
if (nbx<x)
{
x-=1;
}
else
{
x+=1;
}
if (nby<y)
{
y-=1;
}
else
{
y+=1;
}
if (nbx===int(x))
{
nbx=intrandom(s,l);
}
if (nby===int(y))
{
nby=intrandom(s,l);
}
kag.back.base.loadImages(%['storage'=>file,left:0,top:0,visible:true]);
kag.back.base.doBoxBlur(x,y);
kag.fore.base.operateRect(0, 0, kag.back.base, 0, 0, w, h);
}
function blackmove(nbnb)
{
this.nbnb=nbnb;
// 开始糊黑= =
if (nbx<x)
{
x-=nbnb;
}
else
{
x+=nbnb;
}
if (nby<y)
{
y-=nbnb;
}
else
{
y+=nbnb;
}
if (nbx===int(x))
{
nbx=intrandom(s,l);
}
if (nby===int(y))
{
nby=intrandom(s,l);
}
kag.fore.base.doBoxBlur(x,y);
}
function exchangeForeBack()
{
return true;
}
}
class dreamPlugin extends KAGPlugin
{
var x;
var y;
var nbx;
var nby;
var s;
var l;
var t;
var w;
var h;
var dreams;
var timer;
var file;
var black;
var nb;
var nbnb;
function dreamPlugin()
{
super.KAGPlugin();
}
function finalize()
{
invalidate timer if timer !== void;
super.finalize(...);
}
function init(x,y,s,l,t,file,w,h,black,nb)
{
this.x=x;
this.y=y;
this.s=s;
this.l=l;
this.t=t;
this.file=file;
this.w=w;
this.h=h;
this.black=black;
this.nb=nb;
nbnb=1;
if(timer !== void) return;
dreams = new dreamGrain(x,y,s,l,file,w,h);
dreams.spawn();
// TIMER
timer = new Timer(onTimer, '');
timer.interval = t;
timer.enabled = true;
}
function uninit()
{
if(timer === void) return;
invalidate timer;
timer = void;
}
function setOptions(elm)
{
return true;
}
function onTimer()
{
dreams.move() if (black!=1);
dream_object.uninit() if (nb<=0&&black==1);
dreams.blackmove(nbnb) if (black==1);
nbnb+=1 if (black==1);
nb-=1 if (black==1);
}
function resetVisibleState()
{
return true;
}
function onStore(f, elm)
{
// 保存
var dic = f.dreams = %[];
dic.init = timer !== void;
dic.x = x;
dic.y = y;
dic.s = s;
dic.l = l;
dic.t = t;
dic.file = file;
dic.w = w;
dic.h = h;
dic.black = black;
dic.nb = nb;
}
function onRestore(f, clear, elm)
{
// 读取
var dic = f.dreams;
if(dic === void || !+dic.init)
{
uninit();
}
else if(dic !== void && +dic.init)
{
init(dic.x,dic.y,dic.s,dic.l,dic.t,dic.file,dic.w,dic.h,dic.black,dic.nb);
}
}
function onStableStateChanged(stable)
{
return true;
}
function onMessageHiddenStateChanged(hidden)
{
return true;
}
function onCopyLayer(toback)
{
return true;
}
function onExchangeForeBack()
{
return true;
}
}
kag.addPlugin(global.dream_object = new dreamPlugin(kag));
// 登録
@endscript
@endif
;登録
@macro name="梦"
@eval exp="mp.x=int(mp.x)" cond="mp.x!=void"
@eval exp="mp.y=int(mp.y)" cond="mp.y!=void"
@eval exp="mp.s=int(mp.最小值)" cond="mp.最小值!=void"
@eval exp="mp.l=int(mp.最大值)" cond="mp.最大值!=void"
@eval exp="mp.t=int(mp.速度)" cond="mp.速度!=void"
@eval exp="mp.w=&sf.游戏尺寸宽" cond="sf.游戏尺寸宽!=void"
@eval exp="mp.h=&sf.游戏尺寸高" cond="sf.游戏尺寸高!=void"
@eval exp="mp.black=1" cond="mp.黑!=void"
@eval exp="mp.black=0" cond="mp.黑==void"
@eval exp="mp.x=10" cond="mp.初始x==void"
@eval exp="mp.y=10" cond="mp.初始y==void"
@eval exp="mp.s=5" cond="mp.最小值==void"
@eval exp="mp.l=20" cond="mp.最大值==void"
@eval exp="mp.t=150" cond="mp.速度==void"
@eval exp="mp.w=800" cond="sf.游戏尺寸宽==void"
@eval exp="mp.h=600" cond="sf.游戏尺寸高==void"
@eval exp="dream_object.init(mp.x,mp.y,mp.s,mp.l,mp.t,mp.文件,mp.w,mp.h,mp.black,void)"
@endmacro
@macro name="梦停"
@if exp="mp.直接"
@eval exp="dream_object.uninit()"
@else
@eval exp="mp.x=int(mp.x)" cond="mp.x!=void"
@eval exp="mp.y=int(mp.y)" cond="mp.y!=void"
@eval exp="mp.s=int(mp.最小值)" cond="mp.最小值!=void"
@eval exp="mp.l=int(mp.最大值)" cond="mp.最大值!=void"
@eval exp="mp.black=1"
@eval exp="mp.x=10" cond="mp.x==void"
@eval exp="mp.y=10" cond="mp.y==void"
@eval exp="mp.s=5" cond="mp.最小值==void"
@eval exp="mp.l=20" cond="mp.最大值==void"
@eval exp="mp.nb=int(mp.帧数)" cond="mp.帧数!=void"
@eval exp="mp.time=int(mp.时间)"" cond="mp.时间!=void"
@eval exp="mp.nb=150" cond="mp.帧数==void"
@eval exp="mp.time=6000" cond="mp.时间==void"
@eval exp="mp.t=int(mp.time/2/mp.nb)"
@eval exp="dream_object.init(mp.x,mp.y,mp.s,mp.l,mp.t,void,void,void,mp.black,mp.nb)"
@if exp=mp.等|mp.等待
@wait time=%time
@endif
@endif
@endmacro
@return[/code]
===
指令说明:
【梦】
同步刷背景层的插件
可以做到梦境的感觉
【文件】必须
背景图片名字
【x/y】
背景开始的x与y的糊度
默认为10
【最小值/最大值】
糊的范围
默认为
最小值5
最大值20
【速度】
单位毫秒
每帧的时间
默认为150毫秒/帧
===
【梦停】
梦境停止
如果不用【直接】属性
为不断的糊到全黑色的效果
【x/y】
开始的x与y的糊度
默认为10
【最小值/最大值】
糊的范围
默认为
最小值5
最大值20
【帧数】
结束用的帧数
默认为150帧
【时间】
结束的时间
默认为6000毫秒
结束的速度为
时间/帧数
(不过速度可能会因为不同的电脑速度会有不同)
【等】
等效果结束再继续
(再另加上等几秒的等待时间为好= =
因为会因速度问题而有还没完全结束的情况)
【直接】
直接停止效果
用法为
例:
[梦 文件=茂密的森林2]
[梦 文件=茂密的森林2 x=15 y=15 最小值=10 最大值=30 速度=80]
[梦停]
[梦停 x=15 y=15 最小值=10 最大值=30 帧数=200 时间=8000 等]
[梦停 直接]
===
关于制作的废话日志= =
[url]http://hi.baidu.com/tranpol/blog/item/c17c8d6303efc0c8e6113acb.html[/url]