fixed sprite animation

This commit is contained in:
ad044 2020-08-31 19:47:39 +04:00
parent 6e53b78fc7
commit 9d7e17bf8f
3 changed files with 13 additions and 7 deletions

View file

@ -203,9 +203,12 @@ const Game = () => {
// only change sprite focus
default:
setCurrentSprite(move);
// toggle hud to go back in
updateHUD();
setTimeout(() => {
// change hud while its hidden
setCurrentSpriteHUD((level_sprite_huds as SpriteHuds)[move]);
// toggle it again to be shown in the new position
updateHUD();
}, 500);
}

View file

@ -13,7 +13,7 @@ export type HUDElementProps = {
bigHudType: string;
longHudPosition: PositionAndScaleProps;
longHUDPosX: Interpolation<any, any>;
longHUDPosX: Interpolation<number, any>;
longHudScale: PositionAndScaleProps;
// boringHudPosition: PositionAndScaleProps;

View file

@ -1,4 +1,4 @@
import React, { useRef } from "react";
import React, { useRef, useMemo } from "react";
import { useFrame, useLoader } from "react-three-fiber";
import * as THREE from "three";
import copland from "../static/sprites/copland.png";
@ -44,11 +44,14 @@ const LevelSprite = (props: LevelSpriteConstructorProps) => {
const nonActiveTexture: any = useLoader(THREE.TextureLoader, spriteSheet[0]);
const activeTexture: any = useLoader(THREE.TextureLoader, spriteSheet[1]);
const uniforms = {
tex1: { type: "t", value: nonActiveTexture },
tex2: { type: "t", value: activeTexture },
timeMSeconds: { value: Date.now() },
};
const uniforms = useMemo(
() => ({
tex1: { type: "t", value: nonActiveTexture },
tex2: { type: "t", value: activeTexture },
timeMSeconds: { value: Date.now() },
}),
[]
);
const vertexShader = `
varying vec2 vUv;