Jackal16 Posted August 18, 2015 Share Posted August 18, 2015 Hi Guys does anyone know if its possible to create text using group.create() ? I tried setting the group classType to Text but just got an exception? Cheers Link to comment Share on other sites More sharing options...
tips4design Posted August 18, 2015 Share Posted August 18, 2015 Try something like this:var myGroup = game.add.group();var text= game.add.text('...');myGroup.add(text); Link to comment Share on other sites More sharing options...
Jackal16 Posted August 18, 2015 Author Share Posted August 18, 2015 Yeah thats what I went for in the end. Looking at the firefox canvas debugger the text seems to require a draw call for each bit of text - does grouping them stop this and make them draw together? Link to comment Share on other sites More sharing options...
tips4design Posted August 18, 2015 Share Posted August 18, 2015 Yeah thats what I went for in the end. Looking at the firefox canvas debugger the text seems to require a draw call for each bit of text - does grouping them stop this and make them draw together?Well, to draw the text you have to draw each letter. It should only be drawn again after that only if you update the text (or some of it's properties). Link to comment Share on other sites More sharing options...
Jackal16 Posted August 18, 2015 Author Share Posted August 18, 2015 Most of the sprites seem to be drawn in one draw call, each text element seems to be drawn in its own call. Link to comment Share on other sites More sharing options...
tips4design Posted August 18, 2015 Share Posted August 18, 2015 Most of the sprites seem to be drawn in one draw call, each text element seems to be drawn in its own call.Because a sprite is a single image, but each letter from a text is a different image/shape requiring drawing. Think of drawing text as drawing a sprite for each letter. Link to comment Share on other sites More sharing options...
rich Posted August 19, 2015 Share Posted August 19, 2015 Phaser.Text uses a single canvas element to render the text to, so it's one texture and one draw call, regardless how much text there is. However BitmapText uses one Sprite for each character within the text string. If the text isn't going to change you can cache it as a bitmap, but if you're using it for something that updates often like a score or health counter then this isn't a sensible option. Link to comment Share on other sites More sharing options...
Recommended Posts