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

Author Topic: sf::Sprite -> function  (Read 1741 times)

0 Members and 1 Guest are viewing this topic.

CL90

  • Newbie
  • *
  • Posts: 12
    • View Profile
sf::Sprite -> function
« on: February 08, 2012, 04:17:12 pm »
hi there!

is it possible to give a pointer to a sf::Sprite into a function?

something like that (verry simple overview):
Code: [Select]
int main(){
  sf:Sprite ship(Image);
  function(ship);
  App.Draw(ship);

  return 0;
}



function(??? *ship){
   .... // calculate something...
   ship.SetRotation(mov.angactual);
}



what typ of pointer is a sf:Sprite? is it a Multipointer?

Zinlibs

  • Full Member
  • ***
  • Posts: 127
    • View Profile
sf::Sprite -> function
« Reply #1 on: February 08, 2012, 04:40:27 pm »
hello !

yes of course :
Code: [Select]

int main()
{
  sf:Sprite ship(Image);
  function(&ship);
  App.Draw(ship);

  return 0;
}

void function(sf::Sprite *ship)
{
   .... // calculate something...
   ship->SetRotation(mov.angactual);
}


but this is better with a reference :
Code: [Select]

int main()
{
  sf:Sprite ship(Image);
  function(ship);
  App.Draw(ship);

  return 0;
}

void function(sf::Sprite &ship)
{
   .... // calculate something...
   ship.SetRotation(mov.angactual);
}
Zoost & Zoom libraries : An easy way to create and handle geometric objets, animate and use them for better graphics !

CL90

  • Newbie
  • *
  • Posts: 12
    • View Profile
sf::Sprite -> function
« Reply #2 on: February 08, 2012, 05:32:08 pm »
thanks!

works perfectly =)

nice to have some people here around! =)

 

anything