improvement: add charDir check on gizmo collision
This commit is contained in:
parent
b48b02d64a
commit
bceda94970
1 changed files with 16 additions and 1 deletions
|
@ -85,7 +85,7 @@ function Player:collisionResponse(col)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if (col.other.type == "btnInput" and col.other.owner.needButton) then
|
if (col.other.type == "btnInput" and col.other.owner.needButton) then
|
||||||
if (self.keys["A"].isPressed) then
|
if (self.keys["A"].isPressed and (self:faceRightDirection(col.other.owner))) then
|
||||||
col.other.owner:doAction()
|
col.other.owner:doAction()
|
||||||
self.haveCollided = true
|
self.haveCollided = true
|
||||||
self.lastCollision = col.other.owner.creationID
|
self.lastCollision = col.other.owner.creationID
|
||||||
|
@ -94,6 +94,21 @@ function Player:collisionResponse(col)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Player:faceRightDirection(other)
|
||||||
|
if (self.charDir == "up") then
|
||||||
|
return (self.y >= other.y + other.h)
|
||||||
|
end
|
||||||
|
if (self.charDir == "down") then
|
||||||
|
return (self.y + self.h <= other.y)
|
||||||
|
end
|
||||||
|
if (self.charDir == "left") then
|
||||||
|
return (self.x >= other.x + other.w)
|
||||||
|
end
|
||||||
|
if (self.charDir == "right") then
|
||||||
|
return (self.x + self.w <= other.x)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function Player:timerResponse(response)
|
function Player:timerResponse(response)
|
||||||
if (response == "changeCharacter") then
|
if (response == "changeCharacter") then
|
||||||
self.canChangeActive = true
|
self.canChangeActive = true
|
||||||
|
|
Loading…
Reference in a new issue