1 decade ago by Gary
Hello all!
I'm new to Impact and game development. I'm not new to JS, but I'm no expert either.
So before I ask my question, I just have to say I've been playing with Impact for a few weekends and I'm simply astounded at how powerful it is and how easy it makes game development. I'm having all kinds of fun over here!!
That said, I'm a bit stuck on something I think should be pretty easy...
I want to spawn a couple of entities in the init function of my game, after the level has been loaded. However, I want to base the start position of these entities on the size of the entities themselves... Basically I'm trying to centre an entity on the screen, thus:
Note that I don't expect the above code to work, I'm just trying to illustrate what I'd like to do.
What I need is access to the properties of the 'Bat' entity, but before the entity is instantiated, so that I can pass the correct position to the spawnEntity function.
This is basically for future proofing, I could specify the starting position manually, or I could spawn the entity and update the position immediately - but this method would allow me to arbitrarily change the size of the entity and screen without updating code.
Does this sound like something I should be able to do? Or is there a better way of doing it?
I'm new to Impact and game development. I'm not new to JS, but I'm no expert either.
So before I ask my question, I just have to say I've been playing with Impact for a few weekends and I'm simply astounded at how powerful it is and how easy it makes game development. I'm having all kinds of fun over here!!
That said, I'm a bit stuck on something I think should be pretty easy...
I want to spawn a couple of entities in the init function of my game, after the level has been loaded. However, I want to base the start position of these entities on the size of the entities themselves... Basically I'm trying to centre an entity on the screen, thus:
ig.game.spawnEntity(EntityBat, (ig.system.width / 2) - (EntityBat.size.x / 2), 100);
Note that I don't expect the above code to work, I'm just trying to illustrate what I'd like to do.
What I need is access to the properties of the 'Bat' entity, but before the entity is instantiated, so that I can pass the correct position to the spawnEntity function.
This is basically for future proofing, I could specify the starting position manually, or I could spawn the entity and update the position immediately - but this method would allow me to arbitrarily change the size of the entity and screen without updating code.
Does this sound like something I should be able to do? Or is there a better way of doing it?