jpperlm

Members
  • Content Count

    4
  • Joined

  • Last visited

  1. jpperlm

    Container With Sprite + Text - Centering Text

    Awesome! It's still slightly off but so much better. Thanks!
  2. I'm struggling to center my text inside a container. I'm not sure how to best do this programmatically. Here I have a sprite circle radius 12.5. let sprite = p.add.sprite(0,0,'circle') let label = p.add.text(-12.5,-12.5,letters,{ fontFamily:'Arial', color:'#000000', align:'center', }).setFontSize(18); var container = p.add.container(rand_x, 50,[sprite,label]).setSize(25, 25); I understand I can play with the position to make this work however it won't work for all shapes and amounts of letters. I'm not understanding the text boundaries logic. Can i set the canvas which the text is on to have a specific size such that the 'align' actually does something?
  3. jpperlm

    Add Text to Sprite without .addChild

    Awesome, figured it out with the physics container.
  4. With the removal of the .addChild functionality i'm confused how to add text to a sprite. I'm relatively new to phaser and tried understanding how to do this with containers but the examples seem to be broken. Currently I have a physics group that i'm using to make my sprites from. var group = this.physics.add.group(); let item = group/create(50,50,'star'); let label = this.add.text(20,20,"random",style); Now if i add these both to a container they don't share physics. Do i need to make a container group and then create the desired physics and interactions relating to the containers as opposed to the sprites? Effectively - what is the best way to add a text snippet to a sprite and have it still follow desired physics and interactions without redeclaring this every time one is created.