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 Alex

Hi,

Why in impact/entity.js whatever I add to check function line:

check: function( other ) {},

doesn't work? I've successfully added what I want to init and update functions, but check doesn't do anything within entity.js, whatever I type there.

1 decade ago by MikeL

If I understand you correctly, you are directly modifying the entity.js code?

If so then whatever entities are subclassed need to call this.parent() either at the begining or end of their check function, depending on when you want the base entity's check code to fire.

This is similar to using the update or init functions and calling to this.parent().

1 decade ago by Alex

Thanks, worked!

However a question, update function works without calling this.parent(), why?

1 decade ago by MikeL

Depends what you mean. In the pong example EntityPuck has no update function. But,it is still called in the base Entity class.

Why is that? Because in game.js during it's own update function, the entities array, containing all spawned entities, is iterated through and each entity's update is called. Since EntityPuck has no subclassed update function, then the parent's update is automatically called. However, anytime you subclass a function, they you have to call this.parent() if you want to also run the parent class's function.

See the documentation for Class for details.
Page 1 of 1
« first « previous next › last »