Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > Mobile > Windows Phone Dev - สอนเขียน App บนโปรแกรม Windows Phone 7 , Windows Phone 8 > รู้จักกับ XNA Game Studio Project for Windows Phone



Clound SSD Virtual Server

รู้จักกับ XNA Game Studio Project for Windows Phone

รู้จักกับ XNA Game Studio Project for Windows Phone หลังจากที่ติดตั้ง Windows Phone SDK และทำการสร้าง Project บน Windows Phone จะมี Project Type ชื่อว่า XNA Game Studio ซึ่งเป็น Project ไว้สำหรับการสร้าง Game ที่จะถูกใช้กับ Windows Phone โดยการเขียน Application ที่เป็น XNA Game จะใช้รูปแบบคำสั่ง Library จาก .NET Framework เช่นเดียว สามารถเขียนได้ทั้ง VB.NET และ C#

XNA Game Project for Windows Phone


ทดสอบโปรแกรม XNA Game Project for Windows Phone

XNA Game Project for Windows Phone

เลือก File -> New -> Project

XNA Game Studio Project for Windows Phone

เลือกเป็น XNA Game Studio 4.0 และเลือกเป็น Windows Phone Game (4.0) และกำหนดชื่อโปรเจคด้านล่าง

XNA Game Studio Project for Windows Phone

เลือก Version ของ Windows Phone

XNA Game Studio Project for Windows Phone

โครงสร้างของ Project โดยค่าของ Default จะอยู่ที่ Game1.cs หรือ .vb








ทดสอบโปรแกรมแบบง่าย ๆ

Game1.cs (C#)
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.Input.Touch;
using Microsoft.Xna.Framework.Media;

namespace WindowsPhoneGame
{
    /// <summary>
    /// This is the main type for your game
    /// </summary>
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;
        string text = "Hello, Windows Phone 7!";
        SpriteFont segoe14;
        Vector2 textPosition;

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            // Frame rate is 30 fps by default for Windows Phone.
            TargetElapsedTime = TimeSpan.FromTicks(333333);

            // Extend battery life under lock.
            InactiveSleepTime = TimeSpan.FromSeconds(1);
        }

        /// <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);

            // TODO: use this.Content to load your game content here
            segoe14 = this.Content.Load<SpriteFont>("Segoe14");
            Vector2 textSize = segoe14.MeasureString(text);
            Viewport viewport = this.GraphicsDevice.Viewport;

            textPosition = new Vector2((viewport.Width - textSize.X) / 2,
                                       (viewport.Height - textSize.Y) / 2);
        }

        /// <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();

            // TODO: Add your update logic here

            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);

            // TODO: Add your drawing code here
            spriteBatch.Begin();
            spriteBatch.DrawString(segoe14, text, textPosition, Color.White);
            spriteBatch.End();

            base.Draw(gameTime);
        }
    }
}


Game1.vb (VB.NET)
Imports System.Collections.Generic
Imports System.Linq
Imports Microsoft.Xna.Framework
Imports Microsoft.Xna.Framework.Audio
Imports Microsoft.Xna.Framework.Content
Imports Microsoft.Xna.Framework.GamerServices
Imports Microsoft.Xna.Framework.Graphics
Imports Microsoft.Xna.Framework.Input
Imports Microsoft.Xna.Framework.Input.Touch
Imports Microsoft.Xna.Framework.Media

Namespace WindowsPhoneGame
	''' <summary>
	''' This is the main type for your game
	''' </summary>
	Public Class Game1
		Inherits Microsoft.Xna.Framework.Game
		Private graphics As GraphicsDeviceManager
		Private spriteBatch As SpriteBatch
		Private text As String = "Hello, Windows Phone 7!"
		Private segoe14 As SpriteFont
		Private textPosition As Vector2

		Public Sub New()
			graphics = New GraphicsDeviceManager(Me)
			Content.RootDirectory = "Content"

			' Frame rate is 30 fps by default for Windows Phone.
			TargetElapsedTime = TimeSpan.FromTicks(333333)

			' Extend battery life under lock.
			InactiveSleepTime = TimeSpan.FromSeconds(1)
		End Sub

		''' <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 Overrides Sub Initialize()
			' TODO: Add your initialization logic here

			MyBase.Initialize()
		End Sub

		''' <summary>
		''' LoadContent will be called once per game and is the place to load
		''' all of your content.
		''' </summary>
		Protected Overrides Sub LoadContent()
			' Create a new SpriteBatch, which can be used to draw textures.
			spriteBatch = New SpriteBatch(GraphicsDevice)

			' TODO: use this.Content to load your game content here
			segoe14 = Me.Content.Load(Of SpriteFont)("Segoe14")
			Dim textSize As Vector2 = segoe14.MeasureString(text)
			Dim viewport As Viewport = Me.GraphicsDevice.Viewport

			textPosition = New Vector2((viewport.Width - textSize.X) / 2, (viewport.Height - textSize.Y) / 2)
		End Sub

		''' <summary>
		''' UnloadContent will be called once per game and is the place to unload
		''' all content.
		''' </summary>
		Protected Overrides Sub UnloadContent()
			' TODO: Unload any non ContentManager content here
		End Sub

		''' <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 Overrides Sub Update(gameTime As GameTime)
			' Allows the game to exit
			If GamePad.GetState(PlayerIndex.One).Buttons.Back = ButtonState.Pressed Then
				Me.[Exit]()
			End If

			' TODO: Add your update logic here

			MyBase.Update(gameTime)
		End Sub

		''' <summary>
		''' This is called when the game should draw itself.
		''' </summary>
		''' <param name="gameTime">Provides a snapshot of timing values.</param>
		Protected Overrides Sub Draw(gameTime As GameTime)
			GraphicsDevice.Clear(Color.CornflowerBlue)

			' TODO: Add your drawing code here
			spriteBatch.Begin()
			spriteBatch.DrawString(segoe14, text, textPosition, Color.White)
			spriteBatch.[End]()

			MyBase.Draw(gameTime)
		End Sub
	End Class
End Namespace


XNA Game Studio Project for Windows Phone

สำหรับข้อมูลการเขียนโปรแกรม XNA Game บน Windows Phone นั้นยังถือว่าน้อยมาก แต่ก็เห็นมีอยู่หลายคลิปในเว็บไซต์ของยูทูป เช่น

Episode 1



http://www.youtube.com/watch?v=MqyrCM1kIL8


Episode 2



http://www.youtube.com/watch?v=ZB0R_EsTQGg


Episode 3



http://www.youtube.com/watch?v=zlmixU4hneQ


Episode 4



http://www.youtube.com/watch?v=F664qzV7jQ0


Episode 5



http://www.youtube.com/watch?v=NwzKcF69p1k


Episode 6



http://www.youtube.com/watch?v=lZPIYpiiWGg


Episode 7



http://www.youtube.com/watch?v=MdgRMtO1ORI

คลิกอื่น ๆ http://www.youtube.com/user/TradeMarkNZ








อื่น ๆ ที่เกี่ยวข้อง
http://msdn.microsoft.com/en-us/library/bb200104.aspx
http://msdn.microsoft.com/en-us/centrum-xna.aspx


   
Share


ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท


ลองใช้ค้นหาข้อมูล


   


Bookmark.   
       
  By : ThaiCreate.Com Team (บทความเป็นลิขสิทธิ์ของเว็บไทยครีเอทห้ามนำเผยแพร่ ณ เว็บไซต์อื่น ๆ)
  Score Rating :  
  Create/Update Date : 2012-09-02 08:46:15 / 2017-03-25 21:27:46
  Download : Download  รู้จักกับ XNA Game Studio Project for Windows Phone
 Sponsored Links / Related

 
เกี่ยวกับ Windows Phone กับ Silverlight และ .NET Framework ด้วย VB.NET / C#
Rating :

 
รู้จักกับ Microsoft Expression Blend for Windows Phone (Silverlight)
Rating :

 
รู้จักกับ Controls เครื่องมือ ต่าง ๆ ที่ใช้สำหรับการเขียนโปรแกรมบน Windows Phone
Rating :

 
การสร้าง Project บน Windows Phone 8 และการรันบน Windows Phone 8 Emulator
Rating :

 
สร้าง Windows Phone ด้วย JavaScript & HTML5 บน WP 8.0 / 8.1
Rating :

 
รู้จักกับ Tools และ Control ใหม่ ๆ ที่อยู่บน Windows Phone 8 SDK และ Visual Studio 2012
Rating :

 
ทำความเข้าโครงสร้าง Model ของ Page ก่อนการเขียน Application บน Windows Phone
Rating :

 
การสร้างกล่อง MessageBox โต้ตอบกับผู้ใช้แบบง่าย ๆ บน Windows Phone
Rating :

 
การใช้งาน Debugging พื้นฐาน ในการเขียน Windows Phone บน Visual Studio
Rating :

 
การสร้าง Event Handler ระหว่าง XAML (Silverlight,WP) กับภาษา VB.NET และ C# (.NET)
Rating :

 
รู้จักกับ Splash Screen กับ SplashScreenImage.jpg , ApplicationIcon.png และ Background.png (WP)
Rating :

 
Windows Phone Free Icons (For Windows Phone 7)
Rating :


ThaiCreate.Com Forum


Comunity Forum Free Web Script
Jobs Freelance Free Uploads
Free Web Hosting Free Tools

สอน PHP ผ่าน Youtube ฟรี
สอน Android การเขียนโปรแกรม Android
สอน Windows Phone การเขียนโปรแกรม Windows Phone 7 และ 8
สอน iOS การเขียนโปรแกรม iPhone, iPad
สอน Java การเขียนโปรแกรม ภาษา Java
สอน Java GUI การเขียนโปรแกรม ภาษา Java GUI
สอน JSP การเขียนโปรแกรม ภาษา Java
สอน jQuery การเขียนโปรแกรม ภาษา jQuery
สอน .Net การเขียนโปรแกรม ภาษา .Net
Free Tutorial
สอน Google Maps Api
สอน Windows Service
สอน Entity Framework
สอน Android
สอน Java เขียน Java
Java GUI Swing
สอน JSP (Web App)
iOS (iPhone,iPad)
Windows Phone
Windows Azure
Windows Store
Laravel Framework
Yii PHP Framework
สอน jQuery
สอน jQuery กับ Ajax
สอน PHP OOP (Vdo)
Ajax Tutorials
SQL Tutorials
สอน SQL (Part 2)
JavaScript Tutorial
Javascript Tips
VBScript Tutorial
VBScript Validation
Microsoft Access
MySQL Tutorials
-- Stored Procedure
MariaDB Database
SQL Server Tutorial
SQL Server 2005
SQL Server 2008
SQL Server 2012
-- Stored Procedure
Oracle Database
-- Stored Procedure
SVN (Subversion)
แนวทางการทำ SEO
ปรับแต่งเว็บให้โหลดเร็ว


Hit Link
   







Load balance : Server 03
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่