collinhover / impactplusplus

Impact++ is a collection of additions to ImpactJS with full featured physics, dynamic lighting, UI, abilities, and more.
http://collinhover.github.com/impactplusplus
MIT License
276 stars 59 forks source link

EntityDestructable and EntityExplosion are frozen by default, and therefore are skipped when drawing. #137

Closed lamphj closed 10 years ago

lamphj commented 10 years ago

Triggers are set to frozen:true by default and are skipped on draw(). EntityDestructable and EntityExplosion inherit from trigger and therefore are also not drawn. This is a little confusing when creating a destructable entity as they are always invisible unless you reset frozen to the EntityExtended default of false. I think it would be better to switch Destructables to not be frozen by default, or to put a warning in the docs to say EntityDestructable by default will not be drawn.

collinhover commented 10 years ago

Hmm, an entity with frozen will only skip update, not draw. How can we replicate this issue?

lamphj commented 10 years ago

You're right. Re-looking at the code, I think the problem is core entity class update function. When an entity is frozen this.currentAnim is never updated.

if (!this.frozen) {
    ...
    if (this.currentAnim) {
        this.currentAnim.update();
    }
}

The easiest way to reproduce the issue is to create a new Entity that extends EntityDestructable with an animSheet, and animSettings. By default I can't get the entity to show on the screen, but switching

frozen:false

on the entity will cause it to be animated on the screen.

collinhover commented 10 years ago

Ah, thanks for pointing that out, and yes I can see where this would be confusing. Setting destructables to non-frozen by default seems to be a reasonable change at this point.

collinhover commented 10 years ago

Dev branch includes this change.