This forum is read only and just serves as an archive. If you have any questions, please post them on

4 years ago by ijed

Hi guys,

I've searched around a bit and couldn't find a similar issue, either here or in general.

I'm new to Impact and have been adapting the jump n run demo to something new.

When constructing my checkpoint entity I used the coin as a base. Problem is, whenever I try running an animation on it I get the cyclic error
Uncaught TypeError: this.currentAnim.update is not a function

I thought this was because the coin entity originally avoided this.parent, so included that instead of the update animation call, but that instead tells me that Draw is not a function.

I've reordered the code several times but the basic thing remains - if I try to play animation it breaks.

Can someone point me in the right direction?

4 years ago by AndrewMast

Hmm. Code?

4 years ago by AndrewMast

It's just that we can't start until you give us your code. Have you done this.addAnim(...) yet?

4 years ago by ijed

Sorry, I thought this would be a n00b gotcha. Here's the code so far:

EntityGraveskull = ig.Entity.extend({
	size: {x: 16, y: 4},
	offset: {x: 8, y: 28},
	type: ig.Entity.TYPE.NONE,
	checkAgainst: ig.Entity.TYPE.A, // Check against friendly
	collides: ig.Entity.COLLIDES.NEVER,
	animSheet: new ig.AnimationSheet( 'media/graves.png', 32, 32 ),
	sfxCollect: new ig.Sound( 'media/sounds/coin.*' ),
	//internal properties
	status: 0,	//0 = inactive, 1 = active
	burned: 0,	//0= usable, 1 = burned
	init: function( x, y, settings ) {
		this.parent( x, y, settings );
		this.zIndex = -10; //draw it behind other stuff
		this.addAnim( 'inactive', 0.1, [0]);
		this.addAnim( 'activate', 0.1, [1,2], true);
		this.addAnim( 'burn', 0.1, [4,5], true);
	update: function() 
		// Do nothing in this update function; don't even call this.parent().
		// The coin just sits there, isn't affected by gravity and doesn't move.
		//manage the animations depending on status of the grave
		if (this.status == 0)
			this.currentAnim = this.anims.inactive;
		else if (this.status == 1)
			this.currentAnim = this.anims.activate.rewind;
		else if (this.status == 2)
			this.currentAnim = this.anims.activated;
		else if (this.status == 3)
			this.currentAnim = this.anims.burn;
		else if (this.status == 4)
			this.currentAnim = this.anims.burned;
		else	//its burned and inactive
			this.currentAnim = this.anims.inactiveburned;
		// We still have to update the animation, though. This is normally done
		// in the .parent() update:
	check: function( other ) 
		// The instanceof should always be true, since the player is
		// the only entity with TYPE.A - and we only check against A.
		if (other instanceof EntityPlayer)
			//if not burned and the player is injured, restore them
			if (( == 1) && (this.burned == 0) )
			{ = 3;		//restore player
				this.status = 1;			//activated;	//play sfx
				/*if( this.currentAnim != this.anims.burn )
					this.currentAnim = this.anims.burn.rewind;*/
				//other.respawnPoint = this.pos.x, this.pos.y+4;
				if( this.currentAnim != this.anims.burn )
					this.currentAnim = this.anims.burn.rewind;;	//play sfx
				//other.respawnPoint = this.pos.x, this.pos.y+4;



4 years ago by ijed

It's a bit confusing because there are multiple states for the object, and they're not yet written.

It works as a waypoint and as a way for the player to restore themselves from a damaged state.

Also, right now the script that plays the animation is disabled to avoid the crash.

I haven't figured out the respawn point code yet either, but no worries :)

Thanks in advance!

4 years ago by AndrewMast

Hmmm. Give me a minute

4 years ago by AndrewMast

Try on update:

4 years ago by ijed

That's interesting.

It logs no animation until I trigger one by playing, at which point it breaks with the same error and some 'not the droids you're looking for' error;

function () {
		this.loopCount = 0;
		this.frame = 0;
		this.tile = this.sequence[0];
		return this;

It does however tell me that the error is originating in entity.js line 101, which is where ImpactJS calls the exact same animation update. Not surprising, I know, but I haven't yet begun digging around in the guts of the system.

So whatever it is I'm provoking is most likely some stupid syntax thing that cripples the engine, or else a similar obvious requirement I've not included...

4 years ago by Joncom

There's a few places in your code where you incorrectly call rewind

// This:
this.currentAnim = this.anims.burn.rewind;
// Should be:
this.currentAnim = this.anims.burn.rewind();

Calling rewind or any of the animation methods like this would cause the issue, because you're not actually setting this.currentAnim to a valid animation.

4 years ago by ijed

Confirmed and fixed.

Thank you!

Is there some sort of debugger or fake compiler I can use for these types of errors?

I doubt I'll be making this particular mistake again, but it's very easy to miss a , or something when writing out large blocks.

4 years ago by Joncom

It's simply important to note that "methods" or "functions" are called with (). Your code was syntactically valid. It just wasn't what the ImpactJS engine expected you to do.


The error makes sense because you were setting this.currentAnim to a function (instead of object with a property called update).

I suppose if you were using something like TypeScript, then a linter could have told you that you set this.currentAnim to an invalid type, however a stable TypeScript version of ImpactJS is not available...
Page 1 of 1
« first « previous next › last »