Page 1 of 1

Weltmeister not loading Entity

Posted: Sat Jan 11, 2014 12:25 am
by Jackolantern
I have picked ImpactJS back up, but have run into a problem I have never had before. My files are set up as the docs require:

Code: Select all

/lib
      /game
                /entities
                         player.js
                /levels
                         level1.js
But now that I have written the basics of my player entity, when I try to load Weltmeister, it gives me the error that there is a file/name mismatch for player. It says in the error that the name should be EntityPlayer, but that is what I have it named. Do you know if there are any other errors that can trigger this error message? Or have I just missed something?

Here is my entity:

Code: Select all

ig.module(
    'game.entities.player'
)
.requires(
    'impact.entity'
)
.defines(function(){
    EntityPlayer = ig.Entity.extend({
        //main properties
        collides: ig.Entity.collides.ACTIVE,
        type: ig.Entity.TYPE.A,
        checkAgainst: ig.Entity.TYPE.B,
        size: {x: 14, y: 14},
        health: 1,
        offset: {x: 1, y: 1},

        //custom properties
        //doubleJumps: 0,

        //set animation sheet
        animSheet: new ig.AnimationSheet('media/player.png', 16, 16),

        init: function(x, y, settings) {
            //add test animations
            this.addAnim('idle', 1, [0]);
            this.addAnim('jumping', 1, [1]);
            this.addAnim('dying', 1, [2]);
            this.addAnim('shootRight', 1, [3]);
            this.addAnim('shootLeft', 1, [4]);
            this.addAnim('wallSlideRight', 1, [5]);
            this.addAnim('wallSlideLeft', 1, [6]);

            //call parent constructor
            this.parent(x, y, settings);
        },

        update: function() {
            //this method called for each frame of the entity

            //react to input
            if (ig.input.pressed('right')) {
                //walk to the right
                this.vel.x = 100;
                //animate walking right if on ground, or flying through air left if in air
            } else if (ig.input.pressed('left')) {
                //walk to the left
                this.vel.x = -100;
                //animate walking left if on ground, or flying through air right if in air
            }

            this.parent();
        },

        draw: function() {
            this.parent();
        }
    });
});
Thank you!

Re: Weltmeister not loading Entity

Posted: Sat Jan 11, 2014 1:44 am
by hallsofvallhalla
your game.js has

Code: Select all

'game.entities.player',
?

open up the level you are trying to load and look at where it is adding the entity to be sure it is correct. If it is giving you this error without loading a level and i bet it does then that means you might have a syntax error in the player.js. Erase all but init and leave it empty and see if it works

Re: Weltmeister not loading Entity

Posted: Sat Jan 11, 2014 4:11 am
by Jackolantern
Yep, I have that in the main.js. I am not sure what you mean about opening up the level and seeing where it is adding the entity, though.

Oh, and I did comment out everything but the init method, and still getting the same thing :(

Thanks for taking a look at this for me :)

Re: Weltmeister not loading Entity

Posted: Sat Jan 11, 2014 5:53 am
by hallsofvallhalla
when you get the error in weltmeister are you loading a level or is trying to load a level? If so check the level.js to make sure the entity is correct. Also check the player.js in the defines section above the init, remove all those just to double check.

Re: Weltmeister not loading Entity

Posted: Sat Jan 11, 2014 6:48 am
by Jackolantern
I was trying to load a level into Weltmeister that I had I made previously, but this was the first time I tried to load it since creating the player.js entity.

But I figured it out with your help! I had forgotten to capitalize COLLIDES in the collision properties. Thank you! :cool:

Re: Weltmeister not loading Entity

Posted: Sat Jan 11, 2014 4:12 pm
by hallsofvallhalla
i knew it had something to do with a syntax error or general error in the entity as it will give that error as a blanket one when something in there is broken. Now you know where to look next time :)

Re: Weltmeister not loading Entity

Posted: Sat Jan 11, 2014 10:41 pm
by Jackolantern
And now I know that any major syntax errors can cause that error, so that really helps out. I do wish there was a way to make the errors a little more explicit, though lol. Thanks again!