I think my question is about programming.
I ve a sprite moving randomly on the screen. And I have two spritefonts. Spritefont1, changes according to the distance of the sprite to the left edge of the screen (x-axis). So, because Sprite.X changes all the time, Spritefont1 value changes too.
What I can’t do is that; when I press a key ( let’s say it is Key.A), I want to write the Spritefont1’s instant value to Spritefont2. So, Spritefont1 will continue changing but Spritefont2 will remain with the value at the moment the ‘A’ key is pressed. I’m very close to do it, but whatever I did I couldnt solve it. Can anyone help?
speedofhorse = (int)(rand.Next(-1, 2));
destRect.X = destRect.X + speedofhorse;
this way the sprite moves to or fro continuously. and my spritefont1 shows the distance ( of course numerically) changing all the time.
Your post is hard to read. If you indent something it will be formatted like code.
How are you changing the SpriteFont?
I want spritefont2 to catch(copy) Spritefont1’s changing value in the moment that I press a key. And show that value, dont go on changing like Spritefont1. When I equalize it works like this : when space bar is pressed, Spritefont2 value continues changing as Spritefont1 does. When I give up pressing, it becomes zero again. So I cant get the instant value.
we can think it as we have two integers. One of them randomly takes values in an adjusted interval. the other integer not valued yet. and when we press a key, the other integer copies the value of first integer at that moment, and shows it.
int a; ( changes randomly)
int b; (no value)
we press spacebar. and b takes the instant value of ‘a’, and shows it on screen as b= …
You need to be much more specific and clear with your questions.
a sprite moving randomly on the screen. And I have two spritefonts.
Spritefont1, changes according to the distance of the sprite to the left
edge of the screen (x-axis)
A spritefont stores text data spriteBatch.
DrawString(…) draws that text to a position you specify.
A sprite is drawn at a position.
It means typically a image or texture. it is drawn with spritebatch.draw(…) to a position you specify.
These take Vector2’s or Rectangles to use as drawing positions.
These are variables that you declare and define in your program.
What you must do is specify exactly.
What you want to happen ! ?
You or your program performs a specific action ! ?
As well as what you do and do not know how to make happen. For the action as well for the result.
You may also ask just one specific question at a time on how to achieve things this often will yield you better answers.
Spritefonts can’t have a value. They are just used to Draw a String at a given position (Vector2)
So you have a Sprite moving randomly, you draw a String next to the Sprite, then if you press A button there should be another String drawn at a fixed position? Just make a Bool if Button is pressed bool = true and if bool = true draw second string at a fixed position.
EDIT: If you have programming questions always post the code what you have so others can understand better.