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

Author Topic: Question about SFML like entity's  (Read 1956 times)

0 Members and 1 Guest are viewing this topic.

Mr_Blame

  • Full Member
  • ***
  • Posts: 192
    • View Profile
    • Email
Question about SFML like entity's
« on: April 16, 2015, 11:29:51 am »
Hello :)

After viewing some sfml tutorials about vertex arrays I have made class called "Canvas"( it is a smaller and simpler replacement of sprite when you don't need full transform stuff). So the question is how to make a function that changes the texture of this "Canvas"?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Question about SFML like entity's
« Reply #1 on: April 16, 2015, 12:36:09 pm »
What's your problem exactly? Don't hesitate to have a look at the source code of sf::Sprite is something is not clear, it's not complicated.
Laurent Gomila - SFML developer

Mr_Blame

  • Full Member
  • ***
  • Posts: 192
    • View Profile
    • Email
Re: Question about SFML like entity's
« Reply #2 on: April 16, 2015, 02:05:29 pm »
How to make a function that changes the texture of myself-made sfml entity that was made with vertex array

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
AW: Question about SFML like entity's
« Reply #3 on: April 16, 2015, 02:23:30 pm »
Pass a different texture through render states when drawing your vertexarray. How you do it in your code, is your job to figure out.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Question about SFML like entity's
« Reply #4 on: April 16, 2015, 02:25:09 pm »
Ehm... just draw the vertex array with another texture? Where's the problem? I assume you know how to write a C++ function, and how to read the documentation about sf::VertexArray...

And please read this post carefully, it will help you get better answers.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Mr_Blame

  • Full Member
  • ***
  • Posts: 192
    • View Profile
    • Email
Re: Question about SFML like entity's
« Reply #5 on: April 16, 2015, 03:25:26 pm »
I know that i must change texture in render states. but the most strange thing is that: when I change the texture - nothing changes. The entity still appears with old texture. :'(
« Last Edit: April 16, 2015, 03:34:57 pm by Mr_Blame »

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Question about SFML like entity's
« Reply #6 on: April 16, 2015, 04:06:27 pm »
Seriously, read the post I linked to, and then post again.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

 

anything