//TODO: Move this animation code to a mob entity, the player should be in the center of the map and not animated. public override void _Process(float delta) { Vector2 direction = inputDirection(); if (direction.x == 0 && direction.y == 0) { } else { KinematicActor ka = null; ActorSprite a = null; foreach (EntityNode enode in nodes) { if (enode.Name.StartsWith("ActorSprite")) { ActorSprite AS = (ActorSprite)enode; a = AS; ka = AS.kinematicActor; } } Sprite sprite = ka.getSprite(); if (direction.x > 0) { sprite.FlipH = true; } else if (direction.x < 0) { sprite.FlipH = false; } Position2D pos2D = ka.getPosition2D(); Vector2 pos = pos2D.Position; var gm = (GameMap)GetNode("/root/scene/gamespace/GameMap"); Vector2 gPos = gm.WorldToMap(pos); Vector2 newGPos = gPos + direction; Vector2 newPos = gm.MapToWorld(newGPos); a.moveTo(newPos); } }
public override void _Ready() { ActorSprite AS = new ActorSprite(0, 0, 0, 0, 16, 24, "res://assets/oryx_roguelike_2.0/Monsters_Scifi.png", this.guid); this.nodes.Add(AS); }