Share via


Getting Started with XBOX 360 Game Development Using Microsoft XNA (si-LK)

XBOX360 ioyd mß>Kl l%Svd ks¾udkh lsrSug m,uqj w,q;a jHdmD;shla Visual Studio 2008 j, wdrමිn lrkak.

 


    

 

 

පලමුව Hello World  ක්‍රමලේඛය  ioyd kj spite font tllA wka;ra.; lrkak.

** **

 

 

tys ku  Arial ලෙස ලබා දෙන්න.

 

පහත ආකාරයට එහි දත්ත වෙනස් කරන්න.

 

<Size>14</Size>

<Style>Regular</Style>

 

Final   Arial.spritefont  file.

** **

<?xml version="1.0" encoding="utf-8"?>

<!--

This file contains an xml description of a font, and will be read by the XNA

Framework Content Pipeline. Follow the comments to customize the appearance

of the font in your game, and to change the characters which are available to draw

with.

-->

<XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics">

  <Asset Type="Graphics:FontDescription">

 

    <!--

    Modify this string to change the font that will be imported.

    -->

    <FontName>Arial</FontName>

 

    <!--

    Size is a float value, measured in points. Modify this value to change

    the size of the font.

    -->

    <Size>14</Size>

 

    <!--

    Spacing is a float value, measured in pixels. Modify this value to change

    the amount of spacing in between characters.

    -->

    <Spacing>0</Spacing>

 

    <!--

    UseKerning controls the layout of the font. If this value is true, kerning information

    will be used when placing characters.

    -->

    <UseKerning>true</UseKerning>

 

    <!--

    Style controls the style of the font. Valid entries are "Regular", "Bold", "Italic",

    and "Bold, Italic", and are case sensitive.

    -->

    <Style>Regular</Style>

 

    <!--

    If you uncomment this line, the default character will be substituted if you draw

    or measure text that contains characters which were not included in the font.

    -->

    <!-- <DefaultCharacter>*</DefaultCharacter> -->

 

    <!--

    CharacterRegions control what letters are available in the font. Every

    character from Start to End will be built and made available for drawing. The

    default range is from 32, (ASCII space), to 126, ('~'), covering the basic Latin

    character set. The characters are ordered according to the Unicode standard.

    See the documentation for more information.

    -->

    <CharacterRegions>

      <CharacterRegion>

        <Start> </Start>

        <End>~</End>

      </CharacterRegion>

    </CharacterRegions>

  </Asset>

</XnaContent>

 

 

ඉන් පසුව Game 1.cs වල class එකක් හදන්න.

 

SpriteFont myfont;

 

ඉන් පසුව LoadContent()  වල font tllA wka;ra.; lrkak.

 

myfont = Content.Load<SpriteFont>("Arial");

 

 

දැන් Draw()  methord එකේ  font එක අදින්න.

 

 

 

spriteBatch.Begin();  

           

 

spriteBatch.DrawString(myfont, "Hello world", new Vector2(10.0f, 10.0f), Color.Black);

** **

** **

spriteBatch.End();  

 

 

අවසානයට   F5  ඹබා කීඩාව ආරමීබ කරන්න.

 

 

 

Game1.cs

 

 

using System;

using System.Collections.Generic;

using System.Linq;

using Microsoft.Xna.Framework;

using Microsoft.Xna.Framework.Audio;

using Microsoft.Xna.Framework.Content;

using Microsoft.Xna.Framework.GamerServices;

using Microsoft.Xna.Framework.Graphics;

using Microsoft.Xna.Framework.Input;

using Microsoft.Xna.Framework.Media;

using Microsoft.Xna.Framework.Net;

using Microsoft.Xna.Framework.Storage;

 

namespace Hello_world_Xbox360Game

{

    /// <summary>

    /// This is the main type for your game

    /// </summary>

    public class Game1 : Microsoft.Xna.Framework.Game

    {

        GraphicsDeviceManager graphics;

        SpriteBatch spriteBatch;

        SpriteFont spritefont; //intilize sprite font

 

        public Game1()

        {

            graphics = new GraphicsDeviceManager(this);

            Content.RootDirectory = "Content";

        }

 

        /// <summary>

        /// Allows the game to perform any initialization it needs to before starting to run.

        /// This is where it can query for any required services and load any non-graphic

        /// related content.  Calling base.Initialize will enumerate through any components

        /// and initialize them as well.

        /// </summary>

        protected override void Initialize()

        {

            // TODO: Add your initialization logic here

 

            base.Initialize();

        }

 

        /// <summary>

        /// LoadContent will be called once per game and is the place to load

        /// all of your content.

        /// </summary>

        protected override void LoadContent()

        {

            // Create a new SpriteBatch, which can be used to draw textures.

            spriteBatch = new SpriteBatch(GraphicsDevice);

 

            spritefont = Content.Load<SpriteFont>("Arial");

            //load the sprite font

 

 

        

        }

 

        /// <summary>

        /// UnloadContent will be called once per game and is the place to unload

        /// all content.

        /// </summary>

        protected override void UnloadContent()

        {

            // TODO: Unload any non ContentManager content here

        }

 

        /// <summary>

        /// Allows the game to run logic such as updating the world,

        /// checking for collisions, gathering input, and playing audio.

        /// </summary>

        /// <param name="gameTime">Provides a snapshot of timing values.</param>

        protected override void Update(GameTime gameTime)

        {

            // Allows the game to exit

            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)

                this.Exit();

 

          

 

            base.Update(gameTime);

        }

 

        /// <summary>

        /// This is called when the game should draw itself.

        /// </summary>

        /// <param name="gameTime">Provides a snapshot of timing values.</param>

        protected override void Draw(GameTime gameTime)

        {

            GraphicsDevice.Clear(Color.CornflowerBlue);

 

            spriteBatch.Begin();    //start the sprite batch process to draw font

            spriteBatch.DrawString(spritefont, "Hello world", new Vector2(100.0f, 100.0f), Color.YellowGreen);

            //draw the font in the screan

            spriteBatch.End();////end the sprite batch process

 

 

            base.Draw(gameTime);

        }

    }

}