studymark26 Posted June 9, 2016 Share Posted June 9, 2016 Hi There, I'm new to Phaser, i want to develop game related to numbers. For this i want to generate random numbers dynamically with coloured circle or rectangle back ground. how to do this in phaser. please help, I have attached sample image. I don't want to create images, then add sprite. Is there a way to do it using graphics and text ? thanks in advance. Regards, StudyMark Link to comment Share on other sites More sharing options...
Taggrin Posted June 9, 2016 Share Posted June 9, 2016 Graphics has a circle function which you can use to make different colored circles: http://phaser.io/examples/v2/display/circle Together with text to add the number it shouldn't be too hard to create what you are looking for . Link to comment Share on other sites More sharing options...
studymark26 Posted June 9, 2016 Author Share Posted June 9, 2016 Hello Taggrin, Thanks for the reply, The idea is the circle and number should be one object, so to apply animations to it. With graphics.drawCircle(300, 300, 100); circle is added to the graphics object. How can I make both number and circle as 1 object. is it possibl ?. if circle is an image, we can use addChild(text) method. is it possible to addChild() to circle drawn with graphics ? sorry it may be trivial, since I'm new, please bear with me.. Thanks & Regards, StudyMark. Link to comment Share on other sites More sharing options...
Taggrin Posted June 9, 2016 Share Posted June 9, 2016 For those kind of things I think you should take a look at bitmaps: http://phaser.io/examples/v2/bitmapdata/radial-gradient Unfortunately I don't have that much experience with it, so I can't really help you with that. Link to comment Share on other sites More sharing options...
studymark26 Posted June 9, 2016 Author Share Posted June 9, 2016 Anyways thanks for the suggestion... bmd doesn't seems to be a option for my case. I'm waiting for some to suggest me on this.... Link to comment Share on other sites More sharing options...
studymark26 Posted June 11, 2016 Author Share Posted June 11, 2016 can some one help me out ... with this one... waiting for help....:-( Link to comment Share on other sites More sharing options...
in mono Posted June 13, 2016 Share Posted June 13, 2016 Just done putting up a quick example, here you go: http://phaser.io/sandbox/edit/jQTPcIqr Didn't comment it, but I think it's pretty self-explanatory. If something is not clear, just ask. This is a way to draw text directly into the bitmapData. The drawback is that it can't be aligned properly. Another way would be to make the circle sprite and the text separately (the text would be an instance of Phaser.Text) then add the two to a group, then act on the group (be it tweens, position, scale or whatever). Link to comment Share on other sites More sharing options...
studymark26 Posted June 13, 2016 Author Share Posted June 13, 2016 Hi in mono, Thank you very much.. for the example, this will do for me... and your second suggestion is also great. I will try it out.... thanks a lot ..... Link to comment Share on other sites More sharing options...
Recommended Posts