kestrelm / Creature_WebGL

2D Skeletal Animation WebGL Runtimes for Creature ( PixiJS, PhaserJS, ThreeJS, BabylonJS, Cocos Creator )
Apache License 2.0
177 stars 33 forks source link

TypeError: this.timeSamplesMap[lookupTime] is undefined #14

Open sampenland opened 5 years ago

sampenland commented 5 years ago

I'm using creature with Phaser 3 (pack version) and I get this:

TypeError: this.timeSamplesMap[lookupTime] is undefined

when the animation ends. Would setting the animation to loop fix this? How do I do that?

My animation code is:

start_animation(name, speed, fade_time) { if(this.creature_object.pack_renderer.activeAnimationName == name) return;

    this.creature_object.pack_renderer.blendToAnimation(name, fade_time);
    this.creature_object.speed = speed;

}

`

kestrelm commented 5 years ago

Hello, Can you post the exact line where it failed? There are many instances of that code. If you know the line number it will be easier to trace from there and diagnose the error.

In terms of looping, there is already a isLooping flag on the pack_renderer_object. When it is true, the animation should loop.

Thanks

sampenland commented 5 years ago

It happens after the animation's last frame finishes. Happens with/without 'isLooping' set to true.

CreaturePackModule.js:90:17

kestrelm commented 5 years ago

Hello, Is it the timeSamplesMap or the lookupTime which is undefined here? Because I am trying out quite a few samples using that module without error...

sampenland commented 5 years ago

I forgot, my starting animation works. The player is idling correctly, it's just when changing the animation - at the end of the loop.

Here is Chrome's output:

Uncaught TypeError: Cannot read property 'beginTime' of undefined at CreaturePackAnimClip.sampleTime (CreaturePackModule.js:90) at CreatureHaxeBaseRenderer.syncRenderData (CreaturePackModule.js:656) at CreaturePackObj.preUpdate (CreaturePackPhaser3Obj.js:95) at UpdateList.sceneUpdate (phaser.js:142559) at EventEmitter.emit (phaser.js:1752) at Systems.step (phaser.js:33955) at SceneManager.update (phaser.js:76167) at Game.step (phaser.js:136783) at TimeStep.step (phaser.js:65590) at step (phaser.js:65826)

Here is my simple class:

`

module.exports = class CreatureObject
{

    constructor(scene, x, y, scale, bin, atlas, starting_animation, start_speed)
   {

    this.creature_object = scene.make.CreaturePackObj({
        byte_data_in: scene.cache.binary.get(bin),
        texture_key: atlas,
        x: x,
        y: y
    });

    this.creature_object.scaleX = scale;
    this.creature_object.scaleY = scale;
    this.scale = scale;
    this.creature_object.pack_renderer.isLooping = true;
    this.start_animation(starting_animation, start_speed, 1);

}

start_animation(name, speed, fade_time)
{
    if(this.creature_object.pack_renderer.activeAnimationName == name) return;

    this.creature_object.pack_renderer.blendToAnimation(name, fade_time);
    this.creature_object.speed = speed;

}

flip_x(right)
{
    if(right)
    {
        this.creature_object.scaleX = this.scale;
    }
    else
    {
        this.creature_object.scaleX = -this.scale;
    }
}

}

`

kestrelm commented 5 years ago

I am still not sure why this is failing, very strange... If you call setActiveAnimation() instead does it run?

kestrelm commented 5 years ago

You might want to check out the basic sample here: http://localhost:8887/Phaser3/Phaser3BasicSample.html

It too blends animations and runs without errors. It could be a useful reference for you.

sampenland commented 5 years ago

setActiveAnimation() works. Thanks. I was probably doing something wrong with blendAnimation...

Thanks for your quick responses and support.