Impact

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

1 decade ago by jelani435

Hey guys, I'm working on adding some movement logic to an entity. Here's the code:

ig.module( 'game.entities.zombie' )
.requires( 'impact.entity' )
.defines(function() {
	EntityZombie = ig.Entity.extend({
		animSheet: new ig.AnimationSheet( 'media/zombie.png', 16, 16),
		size: {x: 8, y:14},
		offset: {x:4, y:2},
		maxVel: {x:100, y: 100},
		flip: false,

		init: function(x, y, settings) {
			this.parent(x, y, settings);
			this.addAnim('walk', 0.7, [0,1,2,3,4,5]);
		}

		update: function() {
			//Return if near an edge
			if(!ig.game.collisionMap.getTile(
				this.pos.x + (this.flip ? +4 : this.size.x -4),
				this.pos.y + this.size.y+1
				)
		) {
				this.flip = !this.flip;
			}
			var xdir = this.flip ? -1 : 1;
			this.vel.x = this.speed * xdir;
			this.currentAnim.flip.x = this.flip;
			this.parent();
		},

whenever I launch my game, I get this error.
Uncaught SyntaxError: Unexpected token ILLEGAL

Can anyone tell me how to fix this?

1 decade ago by jelani435

It also says the error is coming from /impact/lib/game/main.js:1

1 decade ago by dominic

You're missing a comma after your init() method:

       init: function(x, y, settings) {
            this.parent(x, y, settings);
            this.addAnim('walk', 0.7, [0,1,2,3,4,5]);
        }, // <- add the comma!
Page 1 of 1
« first « previous next › last »