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

7 years ago by ShawnSwander

Would it be faster to load entity animation sheets in the preloader as a varriable and set entities to the sheet rather than have a new sheet for each entity?

Essentially is this
before main.init()
MyGame = ig.Game.extend({
enemyanimSheet:    new ig.AnimationSheet( 'media/mob.png', 60, 60 ),
...

then in the enemy entity
EntityEnemy = ig.Entity.extend({
      animSheet: ig.game.enemyanimSheet,
   ...

faster than this
EntityEnemy = ig.Entity.extend({
      animSheet: new ig.AnimationSheet( 'media/mob.png', 60, 60 ),
   ...

I'm wanting to initiate up to 200 enemies per level that my database will move around

None of my enemies have animated images each tile represents a different image.

7 years ago by Joncom

Performance-wise, it will not make any difference whatsoever. Whether you do your first, second, or third method, they will all be preloaded. See below.

As for what makes more sense logically, I'd keep your entity related image resource out of your main.js file.

MyGame = ig.Game.extend({
    // This image will be loaded by the preloader. It is created
    // as soon as the script is executed
    titleImage: new ig.Image( 'media/title.png' ),
    
    init: function() {
        // This image file will NOT be loaded by the preloader. The
        // init() method is only called after the preloader finishes
        // and the game is started.
        this.backgroundImage = new ig.Image( 'media/background.png' );
    }
});

7 years ago by ShawnSwander

I did some testing and found out anything preloaded (before init() does load a little faster.

7 years ago by Jerczu

Quote from ShawnSwander
I did some testing and found out anything preloaded (before init() does load a little faster.


We are talking in milliseconds if anything... Plus I am pretty sure a lot of resources are being preloaded during game load.

What is worth doing is preloading your sound cues as these do tend to lag a bit.
Page 1 of 1
« first « previous next › last »