Showing posts with label XNA. Show all posts
Showing posts with label XNA. Show all posts

Creating a Blinking Text in XNA

  • 0
Sometimes, just plain text is boring.
You want something fancier, like ..Fading text!
Well.. not that exciting. But you get the idea.

So, how to do that?
I assume you've already understand how to use spriteFont, 
After you've created spriteFont and about to draw it to the screen using DrawString method, use DrawString parameter which is use R,G,B,A rather than predefined Color. Like this :



This allow you to customize color and of course.. Alpha blending.
Update the variable in Update method as you like.

public override void Draw( GameTime gameTime)
        {
            spriteBatch.Begin();
            spriteBatch.DrawString(yourSpriteFont, stringnya, posisi,

             new Color (0,0,0,i));

            spriteBatch.End();
           
            base.Draw(gameTime);
        }

public override void Update( GameTime gameTime)
        {
            switch (color) {
                case 0 :
                    i += 5;
                    if (i == 255)
                        color = 1;
                    break;
                case 1 :
                    i -= 5;
                    if (i == 0)
                        color = 0;
                    break;
            }
        }
You can also customize Color and fade depends on time using gameTime.ElapsedGameTime.Milliseconds if you want.

[XNA] Nambahin Sound ke XNA make XACT

  • 0
Kalalu selama ini masukin sound make API, gimana caranya masukin make XACT?



Langkah-langkahnya :
- Create New di XACT, masukin ke Project
- Create New di Sound Bank sama Wave Bank
- Drag n Drop File Musiknya ke Wave Bank
- Load di Content.Load, audioEngine, waveBank, soundBank