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 coreysnyder

Below is an entity I created. I didn't get very far before realizing that the update method was not being executed on my game loop. Any idea why the init console stmts happen, but not the update?

Here's the code:
ig.module(
    'game.entities.enemyspawner'
)
.requires(
    'impact.entity'
)
.defines(function(){

    EntityEnemyspawner = ig.Entity.extend({
        size: {x: 8, y: 8},
        _wmDrawBox: true, // Used for adding a square to the level editor
        _wmBoxColor: 'rgba(255, 0, 0 ,0.7)',
        init: function( x, y, settings ) {
            this.parent( x, y, settings );
            console.log("ENEMY SPAWNER",settings);

        },
        update: function(){
            console.log("Entity UPDATE");
            this.parent();
        }
    });
});

1 decade ago by ape

I've asked myself this same thing before then realized that I was only showing errors in the console.

Speaking of errors - are seeing any in the console?

What happens if, right after the console.log line, you add ig.system.stopRunLoop(); - does the game stop?

1 decade ago by quidmonkey

Did you spawn the Entity? Did you add the Entity to a level?

1 decade ago by coreysnyder

@Ape - I'll try that as soon as I get home. I wondered if maybe that the console was getting squashed somewhere as well. I will add in that stopRunLoop and see if the game continues running. I sorta hope that's what happens so i know its not some strange bug.

@quidmonkey - I did spawn the entity. I call it on my level change and then I create an instance of the enemy spawner passing a configuration object containing times at which monsters should spawn. Then later I plan to include a timer which releases monsters when their time comes.

@All It's weird b/c I follow the cookie-cutter method for creating an entity. I think I've seen an issue like this before where I was spawning an analog stick entity on screen. And the only way to get it to actually work was if I first dropped at least 1 copy of the analog stick entity into the level via Wetlmeister. Once it was registered that way, it would work just fine. If I opened weltmeister and removed it, it'd just stop working completely and the analog stick would never show up.

1 decade ago by coreysnyder

Quote from ape
I've asked myself this same thing before then realized that I was only showing errors in the console.

Speaking of errors - are seeing any in the console?

What happens if, right after the console.log line, you add ig.system.stopRunLoop(); - does the game stop?


-Nope, it keeps right on chugging along. So I guess this code is legitimately not getting run. But why?

Here's the code I use to spawn the entity:
##
ig.game.spawnEntity(EntityEnemyspawner, 115, 200);##

Here's what I see in the log:
ENEMY SPAWNER -> Object

What I'd expect to see is a spam of "Entity UPDATE"

1 decade ago by coreysnyder

This issue was resolved by adding the entity to the main.js requires block. Such an easy thing to forget! Lesson learned!
Page 1 of 1
« first « previous next › last »