Jump to content

[Problem]Graphics object -> Differant Width when drawing


Teckniel
 Share

Recommended Posts

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.
image.thumb.png.74cc1716a14bdf5b575098b646863d37.png

 

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 by Teckniel
Typo
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by Teckniel
added
Link to comment
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...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...