Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sampenland opened this issue Nov 5, 2019 · 7 comments
Open

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

sampenland opened this issue Nov 5, 2019 · 7 comments

Comments

@sampenland
Copy link

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
Copy link
Owner

kestrelm commented Nov 5, 2019

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
Copy link
Author

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

CreaturePackModule.js:90:17

@kestrelm
Copy link
Owner

kestrelm commented Nov 6, 2019

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
Copy link
Author

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
Copy link
Owner

kestrelm commented Nov 6, 2019

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

@kestrelm
Copy link
Owner

kestrelm commented Nov 7, 2019

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
Copy link
Author

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

Thanks for your quick responses and support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants