游戏开始创建玩家设置初始位置时使用动画
This commit is contained in:
@@ -473,32 +473,39 @@ function loadGame(M,ifQuickPlay)--Load a mode and go to game scene
|
||||
SFX.play("enter")
|
||||
end
|
||||
end
|
||||
function resetPlayerPosition()--Set position & size for every players
|
||||
function initPlayerPosition()--Set initial position for every player
|
||||
local L=PLAYERS.alive
|
||||
L[1]:setPosition(340,75)
|
||||
for i=1,#L do
|
||||
L[i]:setPosition(640,-62,0)
|
||||
end
|
||||
resetPlayerPosition()
|
||||
end
|
||||
function resetPlayerPosition()--Set position & size for every player
|
||||
local L=PLAYERS.alive
|
||||
L[1]:movePosition(340,75,1)
|
||||
if #L<=5 then
|
||||
if L[2]then L[2]:setPosition(965,390,.5)end
|
||||
if L[3]then L[3]:setPosition(965,30,.5)end
|
||||
if L[4]then L[4]:setPosition(20,390,.5)end
|
||||
if L[5]then L[5]:setPosition(20,30,.5)end
|
||||
if L[2]then L[2]:movePosition(965,390,.5)end
|
||||
if L[3]then L[3]:movePosition(965,30,.5)end
|
||||
if L[4]then L[4]:movePosition(20,390,.5)end
|
||||
if L[5]then L[5]:movePosition(20,30,.5)end
|
||||
elseif #L==49 then
|
||||
local n=2
|
||||
for i=1,4 do for j=1,6 do
|
||||
L[n]:setPosition(78*i-54,115*j-98,.09)
|
||||
L[n]:movePosition(78*i-54,115*j-98,.09)
|
||||
n=n+1
|
||||
end end
|
||||
for i=9,12 do for j=1,6 do
|
||||
L[n]:setPosition(78*i+267,115*j-98,.09)
|
||||
L[n]:movePosition(78*i+267,115*j-98,.09)
|
||||
n=n+1
|
||||
end end
|
||||
elseif #L==99 then
|
||||
local n=2
|
||||
for i=1,7 do for j=1,7 do
|
||||
L[n]:setPosition(46*i-36,97*j-72,.068)
|
||||
L[n]:movePosition(46*i-36,97*j-72,.068)
|
||||
n=n+1
|
||||
end end
|
||||
for i=15,21 do for j=1,7 do
|
||||
L[n]:setPosition(46*i+264,97*j-72,.068)
|
||||
L[n]:movePosition(46*i+264,97*j-72,.068)
|
||||
n=n+1
|
||||
end end
|
||||
end
|
||||
@@ -547,7 +554,7 @@ function resetGameData(replaying)
|
||||
|
||||
destroyPlayers()
|
||||
GAME.curMode.load()
|
||||
resetPlayerPosition()
|
||||
initPlayerPosition()
|
||||
restoreVirtualKey()
|
||||
if GAME.modeEnv.task then
|
||||
for i=1,#PLAYERS do
|
||||
|
||||
@@ -6,6 +6,7 @@ local Player={}--Player class
|
||||
|
||||
local int,ceil,rnd=math.floor,math.ceil,math.random
|
||||
local max,min=math.max,math.min
|
||||
local lg=math.log10
|
||||
local ins,rem=table.insert,table.remove
|
||||
local ct=coroutine
|
||||
|
||||
@@ -153,19 +154,25 @@ local function task_movePosition(P,x,y,size)
|
||||
local x1,y1,size1=P.x,P.y,P.size
|
||||
while true do
|
||||
coroutine.yield()
|
||||
x1=x1*.93+x*.07
|
||||
y1=y1*.93+y*.07
|
||||
size1=size1*.93+size*.07
|
||||
if(x1-x)^2+(y1-y)^2<6.26 then
|
||||
local d=((x1-x)^2+(y1-y)^2)^.5
|
||||
if d<.626 then
|
||||
P:setPosition(x,y,size)
|
||||
return true
|
||||
else
|
||||
d=max(.08-lg(d)*.02,.016)
|
||||
x1=x1+(x-x1)*d
|
||||
y1=y1+(y-y1)*d
|
||||
size1=size1+(size-size1)*d
|
||||
P:setPosition(x1,y1,size1)
|
||||
end
|
||||
end
|
||||
end
|
||||
local function checkPlayer(obj,Ptar)
|
||||
return obj.args[1]==Ptar
|
||||
end
|
||||
function Player.movePosition(P,x,y,size)
|
||||
P:newTask(task_movePosition,x,y,size or P.size)
|
||||
TASK.removeTask_iterate(checkPlayer,P)
|
||||
TASK.new(task_movePosition,P,x,y,size or P.size)
|
||||
end
|
||||
|
||||
function Player.set20G(P,if20g,init)--Only set init=true when initialize CC, do not use it
|
||||
|
||||
Reference in New Issue
Block a user