攻击特效和徽章特效并入sysFX
This commit is contained in:
@@ -6,6 +6,37 @@ local ins,rem=table.insert,table.remove
|
||||
local fx={}
|
||||
|
||||
local FXupdate={}
|
||||
function FXupdate.badge(S,dt)
|
||||
S.t=S.t+dt
|
||||
if S.t<.2 then
|
||||
S.x,S.y=S.x1-14,S.y1-14
|
||||
elseif S.t<.8 then
|
||||
local t=((S.t-.2)*1.6667)
|
||||
t=(3-2*t)*t*t
|
||||
S.x,S.y=S.x1*(1-t)+S.x2*t-14,S.y1*(1-t)+S.y2*t-14
|
||||
else
|
||||
S.x,S.y=S.x2-14,S.y2-14
|
||||
end
|
||||
return S.t>=1
|
||||
end
|
||||
function FXupdate.attack(S,dt)
|
||||
S.t=S.t+dt
|
||||
local L=S.drag
|
||||
if S.t>.8 then
|
||||
S.rad=S.rad*1.05+.1
|
||||
S.x,S.y=S.x2,S.y2
|
||||
elseif S.t>.2 then
|
||||
local t=(S.t-.2)*1.6667
|
||||
t=(3-2*t)*t*t
|
||||
S.x,S.y=S.x1*(1-t)+S.x2*t,S.y1*(1-t)+S.y2*t
|
||||
|
||||
ins(L,S.x)ins(L,S.y)
|
||||
end
|
||||
if #L==4+4*setting.atkFX then
|
||||
rem(L,1)rem(L,1)
|
||||
end
|
||||
return S.t>1
|
||||
end
|
||||
function FXupdate.ripple(S,dt)
|
||||
S.t=S.t+dt*S.rate
|
||||
return S.t>=1
|
||||
@@ -20,9 +51,36 @@ function FXupdate.shade(S,dt)
|
||||
end
|
||||
|
||||
local FXdraw={}
|
||||
function FXdraw.badge(S)
|
||||
gc.setColor(1,1,1,S.t<.2 and S.t*.6 or S.t<.8 and 1 or(1-S.t)*.6)
|
||||
gc.draw(IMG.badgeIcon,S.x,S.y)
|
||||
end
|
||||
function FXdraw.attack(S)
|
||||
gc.setLineWidth(5)
|
||||
gc.push("transform")
|
||||
local t=S.t
|
||||
local a=(t<.2 and t*5 or t<.8 and 1 or 5-t*5)*S.a
|
||||
local L=S.drag
|
||||
local len=#L
|
||||
local r,g,b=S.r,S.g,S.b
|
||||
local rad,crn=S.rad,S.corner
|
||||
for i=1,len,2 do
|
||||
gc.setColor(r,g,b,.4*a*i/len)
|
||||
gc.translate(L[i],L[i+1])
|
||||
gc.rotate(t*.1)
|
||||
gc.circle("fill",0,0,rad,crn)
|
||||
gc.rotate(-t*.1)
|
||||
gc.translate(-L[i],-L[i+1])
|
||||
end
|
||||
gc.translate(S.x,S.y)
|
||||
gc.rotate(t*6)
|
||||
gc.setColor(r,g,b,a*.5)gc.circle("line",0,0,rad,crn)
|
||||
gc.setColor(r,g,b,a)gc.circle("fill",0,0,rad,crn)
|
||||
gc.pop()
|
||||
end
|
||||
function FXdraw.ripple(S)
|
||||
setWidth(2)
|
||||
local t=S.t
|
||||
setWidth(2)
|
||||
setColor(1,1,1,1-t)
|
||||
gc.circle("line",S.x,S.y,t*(2-t)*S.r)
|
||||
end
|
||||
@@ -51,6 +109,31 @@ function sysFX.draw()
|
||||
end
|
||||
end
|
||||
|
||||
function sysFX.newBadge(x1,y1,x2,y2)
|
||||
fx[#fx+1]={
|
||||
update=FXupdate.badge,
|
||||
draw=FXdraw.badge,
|
||||
t=0,
|
||||
x=x1,y=y1,
|
||||
x1=x1,y1=y1,
|
||||
x2=x2,y2=y2,
|
||||
}
|
||||
end
|
||||
function sysFX.newAttack(x1,y1,x2,y2,rad,corner,type,r,g,b,a)
|
||||
fx[#fx+1]={
|
||||
update=FXupdate.attack,
|
||||
draw=FXdraw.attack,
|
||||
t=0,
|
||||
x=x1,y=y1,
|
||||
x1=x1,y1=y1,--Start pos
|
||||
x2=x2,y2=y2,--End pos
|
||||
rad=rad,
|
||||
corner=corner,
|
||||
type=type,
|
||||
r=r,g=g,b=b,a=a,
|
||||
drag={},--Afterimage coordinate list
|
||||
}
|
||||
end
|
||||
function sysFX.newRipple(duration,x,y,r)
|
||||
fx[#fx+1]={
|
||||
update=FXupdate.ripple,
|
||||
|
||||
Reference in New Issue
Block a user