Creature_WebGL icon indicating copy to clipboard operation
Creature_WebGL copied to clipboard

TypeError: this.timeSamplesMap[lookupTime] is undefined

Open sampenland opened this issue 5 years ago • 7 comments

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;

}

`

sampenland avatar Nov 05 '19 18:11 sampenland

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

kestrelm avatar Nov 05 '19 21:11 kestrelm

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

CreaturePackModule.js:90:17

sampenland avatar Nov 06 '19 13:11 sampenland

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...

kestrelm avatar Nov 06 '19 13:11 kestrelm

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;
	}
}

}

`

sampenland avatar Nov 06 '19 15:11 sampenland

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

kestrelm avatar Nov 06 '19 22:11 kestrelm

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.

kestrelm avatar Nov 07 '19 11:11 kestrelm

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

Thanks for your quick responses and support.

sampenland avatar Nov 07 '19 13:11 sampenland