improvement(battler): rework 3D actions
This commit is contained in:
parent
0f327d1de2
commit
bc9215fae8
1 changed files with 20 additions and 4 deletions
|
@ -23,6 +23,7 @@ function Battler:new(world, x, y, z, owner)
|
||||||
self.start = {}
|
self.start = {}
|
||||||
self.start.x = x
|
self.start.x = x
|
||||||
self.start.y = y
|
self.start.y = y
|
||||||
|
self.start.z = z
|
||||||
self.start.direction = self.direction
|
self.start.direction = self.direction
|
||||||
|
|
||||||
self:initMovementSystem()
|
self:initMovementSystem()
|
||||||
|
@ -155,6 +156,7 @@ end
|
||||||
|
|
||||||
function Battler:goTo(dx, dy, duration, easing)
|
function Battler:goTo(dx, dy, duration, easing)
|
||||||
local easing = easing or 'inOutQuad'
|
local easing = easing or 'inOutQuad'
|
||||||
|
self:stopMoving()
|
||||||
if duration > 0 then
|
if duration > 0 then
|
||||||
self.tweens:setNamedTween("goTo", 0, duration, {x = dx, y = dy}, easing)
|
self.tweens:setNamedTween("goTo", 0, duration, {x = dx, y = dy}, easing)
|
||||||
end
|
end
|
||||||
|
@ -164,6 +166,20 @@ function Battler:goTo(dx, dy, duration, easing)
|
||||||
self.movementType = MOVEMENT_TWEENER
|
self.movementType = MOVEMENT_TWEENER
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Battler:goTo3D(dx, dy, dz, duration, easing)
|
||||||
|
local easing = easing or 'inOutQuad'
|
||||||
|
self:stopMoving()
|
||||||
|
self:stopJumping()
|
||||||
|
self.jump.useDefaultAnimation = false
|
||||||
|
if duration > 0 then
|
||||||
|
self.tweens:setNamedTween("goTo", 0, duration, {x = dx, y = dy, z = dz}, easing)
|
||||||
|
end
|
||||||
|
self.tweens:newTimer(duration + 0.02, "goTo")
|
||||||
|
self.tweens:newTimer(duration + 0.02, "resetMovement")
|
||||||
|
|
||||||
|
self.movementType = MOVEMENT_TWEENER
|
||||||
|
end
|
||||||
|
|
||||||
function Battler:updateTweenerSpeed(dt)
|
function Battler:updateTweenerSpeed(dt)
|
||||||
self.xspeed = (self.x - self.xprevious) / dt
|
self.xspeed = (self.x - self.xprevious) / dt
|
||||||
self.yspeed = (self.y - self.yprevious) / dt
|
self.yspeed = (self.y - self.yprevious) / dt
|
||||||
|
@ -216,15 +232,15 @@ end
|
||||||
|
|
||||||
function Battler:setJump(power, bounceNumber, useDefaultAnimation)
|
function Battler:setJump(power, bounceNumber, useDefaultAnimation)
|
||||||
self.zspeed = power
|
self.zspeed = power
|
||||||
self.jump.spin = (useDefaultAnimation == false)
|
self.jump.useDefaultAnimation = useDefaultAnimation
|
||||||
self.jump.bounceNumber = bounceNumber
|
self.jump.bounceNumber = bounceNumber
|
||||||
self.jump.isJumping = true
|
self.jump.isJumping = true
|
||||||
end
|
end
|
||||||
|
|
||||||
function Battler:jumpTo(dx, dy, height, speed, spinjump)
|
function Battler:jumpTo(dx, dy, height, speed, useDefaultAnimation)
|
||||||
height = height or 4
|
height = height or 4
|
||||||
speed = speed or 8
|
speed = speed or 8
|
||||||
self:setJump(height, 0, spinjump)
|
self:setJump(height, 0, useDefaultAnimation)
|
||||||
local dir = utils.math.pointDirection(self.x, self.y, dx, dy)
|
local dir = utils.math.pointDirection(self.x, self.y, dx, dy)
|
||||||
local hspeed, vspeed = utils.math.lengthdir(speed, dir)
|
local hspeed, vspeed = utils.math.lengthdir(speed, dir)
|
||||||
self:setMotion(hspeed, vspeed)
|
self:setMotion(hspeed, vspeed)
|
||||||
|
@ -232,7 +248,7 @@ function Battler:jumpTo(dx, dy, height, speed, spinjump)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Battler:jumpBack(height, speed)
|
function Battler:jumpBack(height, speed)
|
||||||
self:jumpTo(self.start.x, self.start.y, height, speed, false)
|
self:jumpTo(self.start.x, self.start.y, height, speed, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Battler:updateJump(dt)
|
function Battler:updateJump(dt)
|
||||||
|
|
Loading…
Reference in a new issue