SFML community forums

Help => Graphics => Topic started by: Helios101 on February 02, 2014, 05:59:33 pm

Title: .
Post by: Helios101 on February 02, 2014, 05:59:33 pm
.
Title: Re: Does anyone use the built in sf move function?
Post by: Jesper Juhl on February 02, 2014, 06:38:56 pm
Sure. move() is useful when you want to move a sprite relative to its current position rather than using absolute position (for which you'd use setPosition()).
I don't see any point in writing custom code for that.
Title: Re: Does anyone use the built in sf move function?
Post by: Grimshaw on February 02, 2014, 06:39:17 pm
I heard a guy was using it.. Don't remember his nickname though.. Sorry!
Title: Re: Does anyone use the built in sf move function?
Post by: G. on February 02, 2014, 08:51:03 pm
Probably A LOT of people.  :-\
Title: Re: Does anyone use the built in sf move function?
Post by: Assassin0795 on February 03, 2014, 03:16:07 pm
My thoughts essentially boil down to "Why do what's already been done for me?" SFML's move() and setPosition() have done all I needed them to do, so I don't feel the need to implement my own movement behavior.
Title: Re: Does anyone use the built in sf move function?
Post by: Hapax on February 07, 2014, 01:21:52 am
I use the move function for a simple drop-down shadow function.
Title: Re: Does anyone use the built in sf move function?
Post by: eigenbom on February 07, 2014, 01:46:44 am
move() irks me. what's it doing there..? a little blemish on an otherwise perfect library. ;D
Title: Re: Does anyone use the built in sf move function?
Post by: legacyblade on February 07, 2014, 07:25:54 am
move() saves a few lines of code if you're just doing something really simple. Granted, I've never used the function (as I usually have an entity who's position the sprite mirrors every frame, I have my own implementation of move() in the entity) . It helps with swift prototyping, and is just pretty convenient when you're getting started.
Title: Re: Does anyone use the built in sf move function?
Post by: eXpl0it3r on February 07, 2014, 09:04:03 am
Like with a lot of functionalities in SFML, the move() function comes from the Simple in SFML. If you use your own entity class, which might then use a sprite internally, there's a high chance that you won't ever use a move(), since you most likely store the position directly in the entity class.

However if you want something very simple (probably not so nice code design), you could be using a sprite instance directly. Thus you're not storing the position separately and thus the move() function will be rather useful.

On the other hand, since the move() function is part of sf::Transformable, it can be quite useful for your own class, since you often just want to move your objects relatively to the old position, so you could just write:
myentity.move(speed * dt.asSeconds());
Where speed is a vector and dt is the frame time stored in the time class.
Title: Re: Does anyone use the built in sf move function?
Post by: Hapax on February 07, 2014, 01:47:33 pm
move() irks me. what's it doing there..? a little blemish on an otherwise perfect library. ;D
It makes more sense to use:
object.move(offset);
than:
object.setPosition(object.getPosition() + offset);
Title: Re: Does anyone use the built in sf move function?
Post by: Nexus on February 07, 2014, 09:04:54 pm
Really passionate discussion for such a topic :D

The purpose of move(v) is obvious, it's a shortcut for setPosition(getPosition() + v). There's not much more to say...