save gravity to object to reduce stack usage
This commit is contained in:
parent
30b31d55e0
commit
a567b0c3a3
@ -5,15 +5,17 @@ using System.Collections.Generic;
|
|||||||
public class Player : KinematicBody2D
|
public class Player : KinematicBody2D
|
||||||
{
|
{
|
||||||
[Export]
|
[Export]
|
||||||
private bool _isInvincible { get; set; } = false;
|
private bool _isInvincible = false;
|
||||||
[Export]
|
[Export]
|
||||||
private bool _canDoubleJump { get; set; } = true;
|
private bool _canDoubleJump = true;
|
||||||
[Export]
|
[Export]
|
||||||
private bool _cayoteTime { get; set; } = true;
|
private bool _cayoteTime = true;
|
||||||
[Export]
|
[Export]
|
||||||
private int _maxWalkSpeed { get; set; } = 50;
|
private int _maxWalkSpeed = 50;
|
||||||
[Export]
|
[Export]
|
||||||
private int _maxRunSpeed { get; set; } = 150;
|
private int _maxRunSpeed = 150;
|
||||||
|
[Export]
|
||||||
|
private int _gravity = (int) ProjectSettings.GetSetting("physics/2d/default_gravity");
|
||||||
private Event _eventBus;
|
private Event _eventBus;
|
||||||
private Vector2 _velocity;
|
private Vector2 _velocity;
|
||||||
private AnimatedSprite _sprite;
|
private AnimatedSprite _sprite;
|
||||||
@ -101,7 +103,7 @@ public class Player : KinematicBody2D
|
|||||||
|
|
||||||
private void ApplyGravity(float delta)
|
private void ApplyGravity(float delta)
|
||||||
{
|
{
|
||||||
_velocity.y += (int) ProjectSettings.GetSetting("physics/2d/default_gravity") * delta * 5;
|
_velocity.y += (int) _gravity * delta * 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void EnterState(State state)
|
private void EnterState(State state)
|
||||||
|
Loading…
Reference in New Issue
Block a user