SFML community forums
Help => Graphics => Topic started by: CL90 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):
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?
-
hello !
yes of course :
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 :
int main()
{
sf:Sprite ship(Image);
function(ship);
App.Draw(ship);
return 0;
}
void function(sf::Sprite &ship)
{
.... // calculate something...
ship.SetRotation(mov.angactual);
}
-
thanks!
works perfectly =)
nice to have some people here around! =)