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

Author Topic: .  (Read 6313 times)

0 Members and 1 Guest are viewing this topic.

Helios101

  • Newbie
  • *
  • Posts: 15
    • View Profile
.
« on: February 02, 2014, 05:59:33 pm »
.
« Last Edit: May 03, 2018, 05:24:47 am by Helios101 »

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Does anyone use the built in sf move function?
« Reply #1 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.
« Last Edit: February 02, 2014, 07:43:10 pm by Jesper Juhl »

Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
Re: Does anyone use the built in sf move function?
« Reply #2 on: February 02, 2014, 06:39:17 pm »
I heard a guy was using it.. Don't remember his nickname though.. Sorry!

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: Does anyone use the built in sf move function?
« Reply #3 on: February 02, 2014, 08:51:03 pm »
Probably A LOT of people.  :-\

Assassin0795

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Does anyone use the built in sf move function?
« Reply #4 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.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Does anyone use the built in sf move function?
« Reply #5 on: February 07, 2014, 01:21:52 am »
I use the move function for a simple drop-down shadow function.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

eigenbom

  • Full Member
  • ***
  • Posts: 228
    • View Profile
Re: Does anyone use the built in sf move function?
« Reply #6 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

legacyblade

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Does anyone use the built in sf move function?
« Reply #7 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.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Does anyone use the built in sf move function?
« Reply #8 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.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Does anyone use the built in sf move function?
« Reply #9 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);
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Does anyone use the built in sf move function?
« Reply #10 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...
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development: