Teckniel Posted June 1, 2021 Share Posted June 1, 2021 (edited) Hello. I currently have a strange problem when drawing lines or a rectangle on a existing container. Containers Layout: ---------------------------------- - World : Container -> SceneManager -> GetActiveScene(): Container When the world get's created i get the ActiveScene from the scene manager. But when the graphics object is rendered it has a differant size then its container where it is placed in. Code Snippet: NewScene(sceneOptions: ISceneOptions): boolean { //this.ActiveScene.removeAllListeners(); //this.ActiveScene.destroy(); this.ActiveScene = new Scene(0xe3d8c3); this.ActiveScene.y = 110; this.ActiveScene.width = 900; this.ActiveScene.height = 400; var graphics = new Graphics(); graphics.beginFill(0xffffff); // draw a rectangle graphics.drawRect(0, 0, 900, this.ActiveScene.height - 25); //this.ActiveScene.addChild(Overlay.Instance.Overlay); this.logger.log('New Scene created!'); this.ActiveScene.addChild(graphics); return true; } Hope anyone can help. Edited June 1, 2021 by Teckniel Typo Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted June 1, 2021 Share Posted June 1, 2021 width is in local coords. Actual width on screen depends on scale. You change width/height of ActiveScene - you have to know how it actually works. It computes bounds (including ALL children, including even line butts that went beyond the screen), and sets scale that it fits. I dont recommend to use it for scene fitting. Quote Link to comment Share on other sites More sharing options...
Teckniel Posted June 1, 2021 Author Share Posted June 1, 2021 (edited) 11 minutes ago, ivan.popelyshev said: width is in local coords. Actual width on screen depends on scale. You change width/height of ActiveScene - you have to know how it actually works. It computes bounds (including ALL children, including even line butts that went beyond the screen), and sets scale that it fits. I dont recommend to use it for scene fitting. Hmm dont't really understand :(. What do you suggest for posible sollution? since i want to draw allot of objects in one container. Like for example a function where you can Draw a wall that is x Px long. Or a container that holds a overlay width lines and text . Ps: I don't want any scale or fitting, just the size i want. i If i add the graphics object straight tothe world container i have no problem Edited June 1, 2021 by Teckniel added Quote Link to comment Share on other sites More sharing options...
Teckniel Posted June 2, 2021 Author Share Posted June 2, 2021 Hope someone can give me a direction on how to solve it. Regards 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.