Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: difference between a Sprite and a Shape.  (Read 4571 times)

0 Members and 1 Guest are viewing this topic.

vams

  • Newbie
  • *
  • Posts: 8
    • View Profile
difference between a Sprite and a Shape.
« on: May 16, 2013, 05:57:08 pm »
I everyone,
another noob question from vams :
What's the difference between a Sprite and a Shape with an attached texture?
More precisely, what are Sprite needed for if I can just put the same texture on a rectangular shape?


zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: difference between a Sprite and a Shape.
« Reply #1 on: May 16, 2013, 06:02:07 pm »
Sprites is directly for defining how a texture gets displayed. A shape can be used to display a texture in the shape you want it, a sprite can not do this. A sprite is needed because making a rectangle shape for every texture is more cumbersome and has slightly more overhead and at the same time just over complicates your code.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: difference between a Sprite and a Shape.
« Reply #2 on: May 16, 2013, 06:05:01 pm »
Both classes are higher class abstraction of a textured quad and thus both come with different helper functions. So in the end it doesn't really matter what you use as long as it does work.

If you want to go a step down from the abstraction, you'll want to take a look at the sf::VertexArray, since that will be able to use a textured quad directly. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/