Tileset animations.
This commit is contained in:
@ -7,6 +7,7 @@
|
||||
#include "asset/AssetManager.hpp"
|
||||
#include "poker/PokerPlayer.hpp"
|
||||
#include "scene/components/Components.hpp"
|
||||
#include "display/animation/TiledSpriteAnimation.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class VNPenny {
|
||||
@ -21,19 +22,26 @@ namespace Dawn {
|
||||
static SceneItem * create(Scene *scene) {
|
||||
auto item = scene->createSceneItem();
|
||||
|
||||
auto meshRenderer = item->addComponent<MeshRenderer>();
|
||||
auto textureAsset = scene->game->assetManager.get<TextureAsset>("texture_penny");
|
||||
auto tilesetAsset = scene->game->assetManager.get<TilesetAsset>("tileset_penny");
|
||||
|
||||
auto meshRenderer = item->addComponent<MeshRenderer>();
|
||||
auto material = item->addComponent<Material>();
|
||||
auto asset = scene->game->assetManager.get<TextureAsset>("texture_penny");
|
||||
auto param = material->getShader()->getParameterByName("u_Text");
|
||||
material->textureValues[param] = &asset->texture;
|
||||
|
||||
auto meshHost = item->addComponent<MeshHost>();
|
||||
auto tiledSprite = item->addComponent<TiledSprite>();
|
||||
tiledSprite->setTileset(&scene->game->assetManager.get<TilesetAsset>("tileset_penny")->tileset);
|
||||
tiledSprite->setSize(glm::vec2(2, 2));
|
||||
|
||||
auto pokerPlayer = item->addComponent<PokerPlayer>();
|
||||
auto animation = item->addComponent<AnimationController>();
|
||||
|
||||
auto param = material->getShader()->getParameterByName("u_Text");
|
||||
material->textureValues[param] = &textureAsset->texture;
|
||||
|
||||
tiledSprite->setTileset(&tilesetAsset->tileset);
|
||||
tiledSprite->setSize(glm::vec2(tilesetAsset->tileset.divX, tilesetAsset->tileset.divY));
|
||||
|
||||
auto anim = new TiledSpriteAnimation(tiledSprite);
|
||||
anim->addSequentialKeyframes(0.1f, 0, 22);
|
||||
anim->loop = true;
|
||||
animation->animation = anim;
|
||||
|
||||
return item;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ namespace Dawn {
|
||||
void stage() override {
|
||||
// Camera
|
||||
auto camera = Camera::create(this);
|
||||
camera->transform->lookAt(glm::vec3(3, 3, 3), glm::vec3(0, 0, 0));
|
||||
camera->transform->lookAt(glm::vec3(50, 50, 50), glm::vec3(0, 0, 0));
|
||||
|
||||
// UI
|
||||
auto canvas = UICanvas::createCanvas(this);
|
||||
|
@ -11,7 +11,8 @@ using namespace Dawn;
|
||||
PokerPlayerDisplay::PokerPlayerDisplay(UICanvas *canvas) :
|
||||
UIEmpty(canvas),
|
||||
labelName(canvas),
|
||||
labelChips(canvas)
|
||||
labelChips(canvas),
|
||||
animChips(&animChipsValue)
|
||||
{
|
||||
this->font = getGame()->assetManager.get<TrueTypeAsset>("truetype_ark");
|
||||
|
||||
@ -36,6 +37,9 @@ PokerPlayerDisplay::PokerPlayerDisplay(UICanvas *canvas) :
|
||||
0.0f
|
||||
);
|
||||
|
||||
// Anim
|
||||
this->animChips.easing = &easeOutQuart;
|
||||
|
||||
// Events
|
||||
getScene()->eventSceneUnpausedUpdate.addListener(this, &PokerPlayerDisplay::onSceneUpdate);
|
||||
}
|
||||
@ -68,8 +72,8 @@ void PokerPlayerDisplay::onPlayerChipsChanged() {
|
||||
std::cout << "Chips" << player->chips << std::endl;
|
||||
|
||||
this->animChips.clear();
|
||||
this->animChips.addKeyframe(&this->animChipsValue, 0.0f, this->animChipsValue);
|
||||
this->animChips.addKeyframe(&this->animChipsValue, 1.0f, this->player->chips);
|
||||
this->animChips.addKeyframe(0.0f, this->animChipsValue);
|
||||
this->animChips.addKeyframe(1.0f, this->player->chips);
|
||||
this->animChips.restart();
|
||||
}
|
||||
|
||||
|
@ -9,12 +9,12 @@
|
||||
#include "poker/PokerPlayer.hpp"
|
||||
#include "asset/AssetManager.hpp"
|
||||
#include "asset/assets/TrueTypeAsset.hpp"
|
||||
#include "display/animation/Animation.hpp"
|
||||
#include "display/animation/SimpleAnimation.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class PokerPlayerDisplay : public UIEmpty {
|
||||
private:
|
||||
Animation<int32_t> animChips;
|
||||
SimpleAnimation<int32_t> animChips;
|
||||
int32_t animChipsValue;
|
||||
|
||||
protected:
|
||||
|
Reference in New Issue
Block a user