Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extending Sprite #6

Closed
tadast opened this issue May 30, 2011 · 2 comments
Closed

Extending Sprite #6

tadast opened this issue May 30, 2011 · 2 comments

Comments

@tadast
Copy link

tadast commented May 30, 2011

Hi,
I am playing with sprite.js and I would like to extend sprite objects to include some methods, say jump(), reset() etc.. I know similar methods already exist in sprite, however, I would like to customize and encapsulate them and make my game more object oriented. I tried to go with prototypal inheritance approach, however sprite prototype is not reachable in the global scope and constructor takes several parameters, therefore I can not do something like

    var Tank = function(){ };

    Tank.prototype = new Sprite;
    Tank.prototype.constructor = Tank;

My javascript skills are quite poor, so maybe I am missing something. How would you suggest I extend Sprite?
I believe making Sprite extendible in some way would add more value to sprite.js, because it would be applicable to frameworks more.
Thanks for your help and for awesome library.

Tadas

@batiste
Copy link
Owner

batiste commented Jun 1, 2011

Hi,

It's indeed an error to not give the Sprite prototype available externaly. I have to digg in the code to see how that could be done.

@batiste
Copy link
Owner

batiste commented Jun 1, 2011

There you can use sjs.Sprite:

e103692

function _Sprite(scene, src, layer)

The only parameter that is really needed is the scene... But I could imagine removing this constraint.

@batiste batiste closed this as completed Jan 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants