codevinsky Posted February 10, 2014 Share Posted February 10, 2014 Using phaser 1.1.4, I want to create a square. This square will be the player. I don't want to have to import an image. I came from flixel, in which I could create a square, give it a color. Everything I've read seems to indicate that I'll have to import an image for a sprite. Can I just create it programmatically without needed external assets, or must every sprite have an image? Link to comment Share on other sites More sharing options...
jpdev Posted February 10, 2014 Share Posted February 10, 2014 You can draw in phaser (using for example the graphics object), like so: http://janpeter.net/perma/phaser/cursorLine.html (use the mouse to draw) - but this graphics object (which you draw in, which is displayed like a sprite) does not (as far as I know) have the body property which is used for physics. (I might be wrong though, or there might be away to attach it to a sprite/ a physics body.) (View the source by rightclick "view source".) Alvin 1 Link to comment Share on other sites More sharing options...
rich Posted February 10, 2014 Share Posted February 10, 2014 I would use a BitmapData object. Create one, draw whatever you need to it, then use it as the texture for your Sprite. codevinsky 1 Link to comment Share on other sites More sharing options...
codevinsky Posted February 11, 2014 Author Share Posted February 11, 2014 There's the answer I was looking for. Perfect. Link to comment Share on other sites More sharing options...
Recommended Posts