updateLookingAngle(entity, camera) {
        if (entity === camera) {
            return;
        }
        const oEntityLoc = entity.position;
        const oCameraLoc = camera.position;
        const fTarget = Geometry.angle(oCameraLoc.x, oCameraLoc.y, oEntityLoc.x, oEntityLoc.y);
        // backup
        let fAngle1 = oEntityLoc.angle + (Math.PI / SPRITE_DIRECTION_COUNT) - fTarget;
        if (fAngle1 < 0) {
            fAngle1 = 2 * Math.PI + fAngle1;
        }
        const nDirection = ((SPRITE_DIRECTION_COUNT * fAngle1 / (2 * Math.PI)) | 0)
            & (SPRITE_DIRECTION_COUNT - 1);
        if (nDirection !== entity.data.backupDirection) {
            entity.data.backupDirection = nDirection;
            entity.sprite.setDirection(nDirection);
        }
    }
/**
     * This will change the animation according to the angle between entity.position.angle and visor.position.angle
     */
This will change the animation according to the angle between entity.position.angle and visor.position.angle
This will change the animation according to the angle between entity . position . angle and visor . position . angle
updateLookingAngle(entity, camera) {
        if (entity === camera) {
            return;
        }
        const oEntityLoc = entity.position;
        const oCameraLoc = camera.position;
        const fTarget = Geometry.angle(oCameraLoc.x, oCameraLoc.y, oEntityLoc.x, oEntityLoc.y);
        let fAngle1 = oEntityLoc.angle + (Math.PI / SPRITE_DIRECTION_COUNT) - fTarget;
        if (fAngle1 < 0) {
            fAngle1 = 2 * Math.PI + fAngle1;
        }
        const nDirection = ((SPRITE_DIRECTION_COUNT * fAngle1 / (2 * Math.PI)) | 0)
            & (SPRITE_DIRECTION_COUNT - 1);
        if (nDirection !== entity.data.backupDirection) {
            entity.data.backupDirection = nDirection;
            entity.sprite.setDirection(nDirection);
        }
    }
updateLookingAngle ( entity , camera ) { if ( entity === camera ) { return ; } const oEntityLoc = entity . position ; const oCameraLoc = camera . position ; const fTarget = Geometry . angle ( oCameraLoc . x , oCameraLoc . y , oEntityLoc . x , oEntityLoc . y ) ; let fAngle1 = oEntityLoc . angle + ( Math . PI / SPRITE_DIRECTION_COUNT ) - fTarget ; if ( fAngle1 < 0 ) { fAngle1 = 2 * Math . PI + fAngle1 ; } const nDirection = ( ( SPRITE_DIRECTION_COUNT * fAngle1 / ( 2 * Math . PI ) ) | 0 ) & ( SPRITE_DIRECTION_COUNT - 1 ) ; if ( nDirection !== entity . data . backupDirection ) { entity . data . backupDirection = nDirection ; entity . sprite . setDirection ( nDirection ) ; } }
This will change the animation according to the angle between entity.position.angle and visor.position.angle
This will change the animation according to the angle between entity . position . angle and visor . position . angle
// backup