Guest User

Untitled

a guest
Oct 19th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. var width = 100, height = 100;
  2. canvas.width = width + 10;
  3. canvas.height = height + 10;
  4. var container = new c.Container();
  5. container.x = 10;
  6. container.y = 10;
  7. container.setBounds(0, 0, width, height);
  8.  
  9. var rect = new c.Shape();
  10. rect.graphics.beginFill('#6e7e8e').drawRect(0, 0, width, height);
  11. container.addChild(rect);
  12.  
  13. var text = new c.Text();
  14. text.set({
  15. text: 'hello',
  16. textAlign: 'center'
  17. });
  18. container.addChild(text);
  19. stage.addChild(container);
  20. stage.update();
  21.  
  22. text.set({
  23. text: 'hello',
  24. });
  25. var b = text.getBounds();
  26. text.x = (width/2) - (b.width/2);
  27. text.y = (height/2) - (b.height/2);
Add Comment
Please, Sign In to add comment