ISOmetric Posted October 22, 2016 Share Posted October 22, 2016 I am looking at this Phaser example, and am simply trying to replace the aliens sprites with simple filled circles drawn by graphics - I've also removed the car, I just want some sprites moving around the area randomly. Unfortunately, the sprites appear with the "no image" graphic. I'm not sure what I am doing wrong here, any help is appreciated: var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create }); var aliens; var sprite; function preload() { sprite = game.make.graphics(0,0); sprite.beginFill(0x00FFFF, 1); sprite.boundsPadding = 0; sprite.drawCircle(50, 50, 100, 100); } function create() { game.physics.startSystem(Phaser.Physics.ARCADE); aliens = game.add.group(); aliens.enableBody = true; for (var i = 0; i < 10; i++) { var s = aliens.create(game.world.randomX, game.world.randomY, sprite); s.name = 'alien' + s; s.body.collideWorldBounds = true; s.body.bounce.setTo(0.8, 0.8); s.body.velocity.setTo(10 + Math.random() * 40, 10 + Math.random() * 40); } } Link to comment Share on other sites More sharing options...
rich Posted October 23, 2016 Share Posted October 23, 2016 You can't have a Graphics object as a Sprite Texture. You need to generate a texture from the Graphics object (Graphics.generateTexture), then use that as the Sprite texture. Link to comment Share on other sites More sharing options...
ISOmetric Posted October 23, 2016 Author Share Posted October 23, 2016 I see. Thanks Rich, I have it working now. Link to comment Share on other sites More sharing options...
Recommended Posts