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 Bushstar

How do I access the property values of my player from other entities?

I only have one instance of the main player defined as game.entities.player. I have other entities that need to change their behaviour depending on the properties of the main player so I need a way to access those properties.

1 decade ago by quidmonkey

Try ig.game.getEntitiesByType() or ig.game.getEntityByName(). For example, in your EntityPlayer's update():

update: function(){
    var enemy = ig.game.getEntitiesByType( EntityEnemy )[0];
    if( enemy.pos.x > player.pos.x ){
        //do something
    }
}

1 decade ago by Bushstar

Thanks for the response. I'm only a day into using Impact so will be asking some stupid questions.
Page 1 of 1
« first « previous next › last »