caymanbruce Posted December 17, 2016 Share Posted December 17, 2016 It seems I can't make a circle shape sprite directly using new Sprite. Can I create a new sprite with a texture generated from a Graphics object which is a circle? For example, I want to create a circle shape sprite. Can I write this? const p = new Graphics(); p.beginFill(0x000000); p.lineStyle(0); p.drawCircle(100, 100, 10); p.endFill(); let sprite = new Sprite(p.generateCanvasTexture()); Quote Link to comment Share on other sites More sharing options...
khalim Posted December 17, 2016 Share Posted December 17, 2016 try using var sprite = new Sprite( someTexture ); sprite.mask = p; Quote Link to comment Share on other sites More sharing options...
caymanbruce Posted December 17, 2016 Author Share Posted December 17, 2016 27 minutes ago, khalim said: try using var sprite = new Sprite( someTexture ); sprite.mask = p; What kind of things can be a texture? Do I have to use an image?What if I want to use less resources? Quote Link to comment Share on other sites More sharing options...
khalim Posted December 17, 2016 Share Posted December 17, 2016 13 minutes ago, caymanbruce said: What kind of things can be a texture? Do I have to use an image?What if I want to use less resources? any valid texture http://pixijs.download/release/docs/PIXI.Sprite.html Quote Link to comment Share on other sites More sharing options...
caymanbruce Posted December 17, 2016 Author Share Posted December 17, 2016 11 hours ago, khalim said: any valid texture http://pixijs.download/release/docs/PIXI.Sprite.html I have found that I can render the graphics into a texture, using RenderTexture, like this: const p = new Graphics(); p.beginFill(0x000000); p.lineStyle(0); p.drawCircle(100, 100, 10); p.endFill(); const t = RenderTexture.create(p.width, p.height); renderer.render(p, t); const sprite = new Sprite(t); sprite.x = 100; This way I can render a circle shape sprite. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.