1 decade ago by alexandre
I'm in the process of implementing an Entity subclass Button--I'll need a lot of those and figure it won't be wasted effort--and have a couple of questions:
1. right now, things are jamming at the ig.input.bind line, with console reporting "Uncaught TypeError: Cannot call method 'bind' of undefined".
2. I'm not clear on what the difference is between an Impact plugin and a subclass.
Thanks in advance
Alex
1. right now, things are jamming at the ig.input.bind line, with console reporting "Uncaught TypeError: Cannot call method 'bind' of undefined".
2. I'm not clear on what the difference is between an Impact plugin and a subclass.
// sample use: play: new EntityButton('media/play.png', 200, 200, this, 'play');
ig.module(
'plugins.button'
)
.requires(
'impact.game',
'impact.entity',
'plugins.input-released'
)
.defines(function()
{
EntityButton = ig.Entity.extend (
{
owner: null,
callback: null,
init: function (path, x, y, owner, callback)
{
// TODO: load image & other things
ig.input.bind (ig.KEY.MOUSE1, 'mouse1');
this.owner = owner;
this.callback = callback;
},
update: function ()
{
// TODO: if mouse released over button, owner callback
},
draw: function ()
{
// TODO: draw ouselves
}
});
});
Thanks in advance
Alex
