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

Author Topic: Convert Sprite to Image  (Read 2095 times)

0 Members and 1 Guest are viewing this topic.

Yukilay

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Convert Sprite to Image
« on: August 28, 2013, 11:57:58 am »
My question is simple: There is any way to converta Sprite to Image? I would like to compare EACH pixel with Color::Trasparent to approach a better collision management (although I'm sure it isn't worth, I want to be aware of the difference).

Thanks guys.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Convert Sprite to Image
« Reply #1 on: August 28, 2013, 12:26:19 pm »
This would be too inefficient (you would have to retrieve the sprite's texture from video memory). Build your "collision map" (a bidimensionnal array of booleans or alpha values, for example) when you load the texture, and then use it for collision detection.
Laurent Gomila - SFML developer

AlexxanderX

  • Full Member
  • ***
  • Posts: 128
    • View Profile
    • AlexanderX
Re: Convert Sprite to Image
« Reply #2 on: August 28, 2013, 05:29:12 pm »
Maybe you should see this topic on wiki https://github.com/SFML/SFML/wiki/Source%3A-Simple-Collision-Detection-for-SFML-2 which has a functions that compare and the alpha value. ;)
Here you can find my blog and tutorials about SFML - http://alexanderx.net/ (died...) - http://web.archive.org/web/20160110002847/http://alexanderx.net/

 

anything