|
| 10 Aug 2012 02:24 PM |
I am using SFML 2.0. I have declared a sprite, and it works fine, except when I rotate it, it is on the wrong center point (orgin). I cannot figure out how to set the orgin. I have tried:
sf::Transformable::setOrigin ( const Vector2f & origin )
But it makes no sense to me. Help please |
|
|
| Report Abuse |
|
|
su8
|
  |
| Joined: 06 Mar 2009 |
| Total Posts: 6334 |
|
|
| 10 Aug 2012 02:26 PM |
just do it like
.setOrigin(sf::Vector2f(sizeX/2,sizeY/2)); |
|
|
| Report Abuse |
|
|
stravant
|
  |
 |
| Joined: 22 Oct 2007 |
| Total Posts: 2893 |
|
|
| 10 Aug 2012 02:26 PM |
| What do you mean it "makes no sense to you"? Do you mean it doesn't do anything, or you don't know how to use it? |
|
|
| Report Abuse |
|
|
su8
|
  |
| Joined: 06 Mar 2009 |
| Total Posts: 6334 |
|
|
| 10 Aug 2012 02:28 PM |
| And btw, I prefer using rectangles with textures instead of just sprites.. |
|
|
| Report Abuse |
|
|
Legend26
|
  |
| Joined: 08 Sep 2008 |
| Total Posts: 10586 |
|
|
| 10 Aug 2012 02:29 PM |
| How come Vector2f isn't shown in the documentation? There's a Vector2 templated class though... |
|
|
| Report Abuse |
|
|
|
| 10 Aug 2012 02:30 PM |
@Stravant I didn't know how to use it.
I finally read a few pieces of code from 1.6 or whatever, then translated it to 2.0, And it works!
character.setOrigin(X,Y);
Thanks for helping guys! |
|
|
| Report Abuse |
|
|
|
| 10 Aug 2012 02:34 PM |
I have a new question: What is the C++ equivalent of wait() |
|
|
| Report Abuse |
|
|
su8
|
  |
| Joined: 06 Mar 2009 |
| Total Posts: 6334 |
|
|
| 10 Aug 2012 02:36 PM |
you don't need wait. seriously. if you want something to happen after certain amount of seconds just check the time from the game loop |
|
|
| Report Abuse |
|
|
|
| 10 Aug 2012 02:37 PM |
@su8 How? I am new-ish at C++ |
|
|
| Report Abuse |
|
|
|
| 10 Aug 2012 02:38 PM |
And I want it to be a "jumping" action. I press the up arrow key, sprite moves up for a set time, then down for a set time. |
|
|
| Report Abuse |
|
|
su8
|
  |
| Joined: 06 Mar 2009 |
| Total Posts: 6334 |
|
|
| 10 Aug 2012 02:39 PM |
uhm
sfml-dev.org/documentation/2.0/classsf_1_1Clock.php |
|
|
| Report Abuse |
|
|
su8
|
  |
| Joined: 06 Mar 2009 |
| Total Posts: 6334 |
|
|
| 10 Aug 2012 02:41 PM |
So this is what you basically want (pseudo-code)
inair = false last_jump = 0
while window is open clear window draw content display window if user input for jump inair=true last_jump = clock time end if inair then if last_jump + delay > clock time character y ++ else character y -- end if last_jump + delay*2 > clock time inair = false end end |
|
|
| Report Abuse |
|
|
su8
|
  |
| Joined: 06 Mar 2009 |
| Total Posts: 6334 |
|
|
| 10 Aug 2012 02:42 PM |
ugh i meant
if last_jump + delay*2 < clock time |
|
|
| Report Abuse |
|
|
su8
|
  |
| Joined: 06 Mar 2009 |
| Total Posts: 6334 |
|
|
| 10 Aug 2012 02:43 PM |
and the delay is the time for the jump/get back down
sryfortriplepost |
|
|
| Report Abuse |
|
|
|
| 10 Aug 2012 03:26 PM |
I think I may have found a solution int wait (int time) { bool iswaitover sf::Clock:restart() int e = sf::Clock::getElapsedTime() if (e = time) iswaitover = true else iswaitover = false } |
|
|
| Report Abuse |
|
|
su8
|
  |
| Joined: 06 Mar 2009 |
| Total Posts: 6334 |
|
| |
|
|
| 10 Aug 2012 03:27 PM |
Owait. Maybe its this (My clock is named "clock"). I won't know until I try I guess
int wait (int time) { bool iswaitover clock:restart() int e = sf::Clock::getElapsedTime() if (e = time) iswaitover = true else iswaitover = false } |
|
|
| Report Abuse |
|
|
su8
|
  |
| Joined: 06 Mar 2009 |
| Total Posts: 6334 |
|
|
| 10 Aug 2012 03:29 PM |
| i posted the pseudo code derp |
|
|
| Report Abuse |
|
|
booing
|
  |
| Joined: 04 May 2009 |
| Total Posts: 6594 |
|
|
| 10 Aug 2012 03:30 PM |
void wait(int t) { cout << "k nob in " << t << " seconds press a key" << "\n"; system("pause"); cout << "noob" << "\n"; } ya us ths it lik pro |
|
|
| Report Abuse |
|
|
|
| 10 Aug 2012 03:51 PM |
| How do I store coordinates as a variable? |
|
|
| Report Abuse |
|
|
|
| 10 Aug 2012 03:53 PM |
>2012 >not using D programming language |
|
|
| Report Abuse |
|
|
|
| 10 Aug 2012 03:53 PM |
| >Not using D programming language. |
|
|
| Report Abuse |
|
|
TheMyrco
|
  |
| Joined: 13 Aug 2011 |
| Total Posts: 15105 |
|
|
| 10 Aug 2012 03:54 PM |
There are multiple ways possible to do that, but here's two:
int x = ..., y = ..., z = ...;
Or:
int coordinate[3] = {x, y ,z};
You can also make a map:
int coordinates[2][3] = {{x, y, z}, {x, y ,z}}; |
|
|
| Report Abuse |
|
|
|
| 10 Aug 2012 03:56 PM |
Umm, whut?
I am using SFML. It is 2D, so only X and Y.
I use characteer:getPosition() |
|
|
| Report Abuse |
|
|
TheMyrco
|
  |
| Joined: 13 Aug 2011 |
| Total Posts: 15105 |
|
|
| 10 Aug 2012 03:57 PM |
A class is possible too:
class coordinate { public: int x, y, z; coordinate(): X = 0, Y = 0, Z = 0 {} coordinate(int x, int y, int z): X = x, Y = y, Z = z {} } |
|
|
| Report Abuse |
|
|