Finished camera controller.

This commit is contained in:
2023-03-21 20:52:17 -07:00
parent 2bd6012297
commit 807f78fcda
9 changed files with 92 additions and 53 deletions

View File

@ -8,6 +8,7 @@
#include "assert/assert.hpp"
#include "util/flag.hpp"
#include "event/Event.hpp"
#include "state/StateEvent.hpp"
namespace Dawn {
class SceneItem;
@ -40,7 +41,8 @@ namespace Dawn {
public:
// I have no idea if I'm keeping this
Event<> eventTransformUpdated;
// Event<> eventTransformUpdated;
StateEvent<> eventTransformUpdated;
SceneItem *item;
/**

View File

@ -1,27 +0,0 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "Prefab.hpp"
#include "ui/UIComponent.hpp"
namespace Dawn {
template<class T, class P>
class UIPrefab :
public Prefab<T, UICanvas, P>
{
public:
static void apply(T *item) {
assertNotNull(item);
P::prefabApply(&item->getGame()->assetManager , item);
}
static T * prefabCreate(UICanvas *canvas) {
T * item = canvas->addElement<T>();
P::apply(item);
return item;
}
};
}

View File

@ -59,6 +59,8 @@ void CharacterController2D::onStart() {
}
}
if(mathAbs<float_t>(moveAmount.x) <= 0.001f && mathAbs<float_t>(moveAmount.y) <= 0.001f) return;
transform->setLocalPosition(
transform->getLocalPosition() + (glm::vec3(moveAmount.x, 0, moveAmount.y) * delta)
);