charlie_says Posted September 8, 2019 Share Posted September 8, 2019 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 Quote Link to comment Share on other sites More sharing options...
mobileben Posted September 8, 2019 Share Posted September 8, 2019 Good question. Curious, what are you trying to do (ie. why don't you want to extend from PIXI.Point)? Are you using Typescript? If so I notice that the objects are not created with prototypes. Quote Link to comment Share on other sites More sharing options...
charlie_says Posted September 8, 2019 Author Share Posted September 8, 2019 PIXI.Point doesn't have point.interpolate. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted September 8, 2019 Share Posted September 8, 2019 PIXI.Point.prototype.something = function() { ... } charlie_says 1 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted September 8, 2019 Share Posted September 8, 2019 dont forget to add it to PIXI.ObservablePoint too. --- Explanation on why do we have two point clases will take too long. Its just the way it is. Quote Link to comment Share on other sites More sharing options...
charlie_says Posted September 8, 2019 Author Share Posted September 8, 2019 thanks! Quote Link to comment Share on other sites More sharing options...
charlie_says Posted September 10, 2019 Author Share Posted September 10, 2019 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.