Quantcast
Channel: Pixi.js Latest Topics
Viewing all articles
Browse latest Browse all 3978

Are graphics and sprites to be kept separate?

$
0
0

Hi folks, 

I'm currently trying to make a ball bounce around the screen. I've done this before in C++/SFML, bog-standard html canvas and in ThreeJs, so now it's Pixi's turn!

What I'd usually do:

  • Make a circle object
  • Fill it with an image; it's fitted, so it'll resize as the circle does
  • Do the maths to make the circle move and bounce around

The problem is, I'm struggling to understand how to pull it together in Pixi:

  • I can make a sprite which takes on the size of the image
  • This can be scaled, and have its width and height set
  • I can make a PIXI.Graphics in the shape of a circle, or I can make a PIXI.Circle (which is what I expect I need)

BUT:

  • I cannot fill the graphics/circle with the sprite, making the image fit the circle

It seems like the image and the circle object are to be kept separate, which seems a bit alien to me. How can I garuantee the graphics/cirlce object matches the shape of the image exactly, and visa versa? 

I've seen this, https://codepen.io/ccorder2/pen/NyvygQ but that doesn't cover the image part. 

What am I missing here? Help appreciated, thanks all!

 


Viewing all articles
Browse latest Browse all 3978

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>