charlie_says

Add functionality to existing PIXI Class

Recommended Posts

Apologies for the basic question, i don't want to extend from a PIXI Class, in this case PIXI.Point, I want to add some functionality to the existing class (if possible)

But, I've not got very far - can anyone give me a hint as to how to do it?

 

Thanks

Share this post


Link to post
Share on other sites

Just as an update, if anyone else is interested. In ES6 you don't need prototype

PIXI.Point.interpolate = function (a, b, f, out) {

    if (typeof out === "undefined") { out = new PIXI.Point(); }

    return out.set(a.x + (b.x - a.x) * f, a.y + (b.y - a.y) * f);

};

PIXI.ObservablePoint.interpolate = function (a, b, f, out) {

    if (typeof out === "undefined") { out = new PIXI.ObservablePoint(); }

    return out.set(a.x + (b.x - a.x) * f, a.y + (b.y - a.y) * f);

};

works fine for me.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.