ozgun Posted October 20, 2020 Share Posted October 20, 2020 Hello, I want to use Container's method in my typescript class. How can i do this? Like this: public addChild( child:PIXI.Container ):PIXI.Container { super.addChild(child); child.x = 0; child.y = -(child.height / 2); var holder:PIXI.Container = new PIXI.Container(); this._itemDictionary[ child.name ] = holder; super.addChild( holder ); holder.addChild( child ); holder.alpha = 0; this.positionItems(); return child; } Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted October 21, 2020 Share Posted October 21, 2020 (edited) Whats stopping you? Except that there might be several children passed there Edited October 21, 2020 by ivan.popelyshev Quote Link to comment Share on other sites More sharing options...
ozgun Posted October 21, 2020 Author Share Posted October 21, 2020 VSCode gives me this attached error Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted October 21, 2020 Share Posted October 21, 2020 (edited) Did you actually look at signature of original method in d.ts file? PixiJS handles cases when several children are mentioned in the method. Edited October 21, 2020 by ivan.popelyshev Quote Link to comment Share on other sites More sharing options...
ozgun Posted October 22, 2020 Author Share Posted October 22, 2020 Ok I've handled it. Thank you. public addChild(...child:PIXI.DisplayObject[]): PIXI.DisplayObject { child[0].x = 0; child[0].y = -((child[0] as PIXI.Container).height / 2); var holder: PIXI.Container = new PIXI.Container(); this._itemDictionary[child[0].name] = holder; super.addChild(holder); holder.addChild(child[0]); holder.alpha = 0; this.positionItems(); return child[0]; } ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted October 22, 2020 Share Posted October 22, 2020 btw, there's "renderable=false" / "renderable=true" switch, alternative to "alpha=0". ITs checked in all "render()" methods in Container . Quote Link to comment Share on other sites More sharing options...
ozgun Posted October 23, 2020 Author Share Posted October 23, 2020 Ok. Thank you. 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.