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

Author Topic: Sprite?  (Read 2050 times)

0 Members and 1 Guest are viewing this topic.

BeautiCode

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
Sprite?
« on: July 10, 2014, 08:38:01 am »
I'm sort of new to this sprites stuff.
For my very first game I used a VertexArray with a rectangle (4 sides).
I want to load a sprite, and make a similar rectangle so I can detect a collision with the image, but all these resources are showing me IntRect(); with sprites and stuff.
I don't understand it, the arguments are:
-Directory
-Left,top,width,height.
 I don't get that, shouldn't it be Top left,bottom left, top right, bottom right?

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Sprite?
« Reply #1 on: July 10, 2014, 08:45:13 am »
Left,top,width,height and top-left,bottom-left,top-right,bottom-right are both valid ways to define a rectangle and converting between them, if needed, is trivial. Which way is prefered is mostly a matter of taste and sometimes convenience in a specific context.

BeautiCode

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
Re: Sprite?
« Reply #2 on: July 10, 2014, 08:55:16 am »
Left,top,width,height and top-left,bottom-left,top-right,bottom-right are both valid ways to define a rectangle and converting between them, if needed, is trivial. Which way is prefered is mostly a matter of taste and sometimes convenience in a specific context.
How do you convert them?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Sprite?
« Reply #3 on: July 10, 2014, 09:06:41 am »
width = right - left

or

right = left + width
Laurent Gomila - SFML developer

BeautiCode

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
Re: Sprite?
« Reply #4 on: July 10, 2014, 09:19:07 am »
width = right - left

or

right = left + width
Ah, I get it :p
But with my previous project, I moved the primitive by adding a number to each vertice value. Could you give me an example of how to do that with sprite?