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

Author Topic: How to add point to sprite?  (Read 1382 times)

0 Members and 1 Guest are viewing this topic.

Mattio91

  • Newbie
  • *
  • Posts: 1
    • View Profile
How to add point to sprite?
« on: January 12, 2011, 01:49:25 pm »
Hi,
I am working on project where I can't use library with collision, so I do it my self and I am wondering does is there some way to add a point to sprite (something like Center but usable only for me). What's important point should rotate and moving with sprite. It's my second project and my English is not so god so be tolerant and explain me how to do it. Thx

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
How to add point to sprite?
« Reply #1 on: January 12, 2011, 05:51:53 pm »
There are several possibilities to achieve what you want. The simplest way is probably a sf::Shape circle (modeling the point) which is drawn over the sf::Sprite. The problem with this approach is that all the attributes (position, rotation, scale, color) of the two objects must be kept consistent manually. This problem can be solved by a sf::Drawable that holds a sf::Sprite and a sf::Shape as member and draws them in its Render() function.

You could also modify the sf::Image directly (set its pixel colors), but then that applies to all sprites using that image.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development: