Added: 2 years ago
From: Whiplashx86
Views: 1,225
Sort by time | Sort by thread (beta)

Link to this comment:

Share to:

All Comments (9)

Sign In or Sign Up now to post a comment!
  • nvm I've fixed it ty:)

  • Ok that works but now the right side is a little too "in" if you know what i mean like

    wall ----> | end of the screen---- |

    sorry if that doesnt explain alot lol

  • so

    if (position.X >= GraphicsDevice.Viewport.Width - spriteFont.MeasureString) ?

    if I do it like that it gives me an error saying

    Operator '-' cannot be applied to operands of type 'int' and 'method group'

  • MeasureString needs a string parameter, and it returns a Vector2. So it needs to be something like this:

    spriteFont.MeasureString("This is a string I want to measure").X

    Also, I would recommend doing it this way:

    if (position.X + spriteFont.MeasureString("This is a string I want to measure").X >= GraphicsDevice.Viewport.Width)

    To do the same thing on the Y axis, use spriteFont.MeasureString("This is a string I want to measure").Y instead.

  • yeah it works fine just the right wall lets the text go in to deep

  • You dont use line spacing, you use the measure string method I mentioned a few comments down.

  • Well here's how I have it now.

    if(position.X >= GraphicsDevice.Viewport.Width - spriteFont.LineSpacing)

  • Does it work?

  • Yeah I've got it bouncing off the top bottom and left walls perfectly but on the right wall it goes in a little too deep and I cant figure out a way to stop it from doing that

  • Okay, you remember in my movement tutorial parts 1 and 2 where I discuss the bouncing with the sprite? We had to take the sprite width into account when we tested the right side (GraphicsDevice.Viewport.Width - player.Width).

    You basically do the same thing, but you use a spriteFont object and call the MeasureString method with a string passed to it. It will give you a Vector2. Then, you need to add it to the position and test to see if its bigger than the viewport.width and viewport.height

  • Thank you for the tutorials but I'm having a bit of trouble on the spriteFont one I'm trying to make the letters move around like the movement tutorial but on the right side of the screen it goes in a little too deep and I cant figure out why.

  • You want the text to bounce like in the movement tutorial?

  • soda dude he makes great tutorials if youu don't like it then find a different tutorial

  • Well I cant change my voice, so I should just stop talking?

  • helpful, but TBH your voice grates on my nerves 4/5 stars

Loading...
Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more