윈도우폰 게임개발 기초
 



윈도우폰 개발에 사용되는 함수와 참조하는 클래스들에 대해서 알아보도록 하자.
실제 윈도우폰 게임 개발을 열었을 때 나오게되는 소스에 대해서 분석해보았다. 
 

using System;
using System.Collections.Generic;
using System.Linq;

using Microsoft.Xna.Framework;//XNA 프레임워크 라이브러리(손쉬운 게임개발)

using Microsoft.Xna.Framework.Audio; // XACT로 만든 프로젝트 및 콘텐츠 오디오 파일을 재생하고 낮은 수준의 인터페이스 방식에서 조작할 수 있는 클래스제공

using Microsoft.Xna.Framework.Content;// 게입에서 사용하는 자원들을 각 파일 포맷에 따리 관리하고 유지하는데 필요한 클래스

using Microsoft.Xna.Framework.GamerServices; // xbox LIVE와 관련된 기능을 담당하는 모듈로 LIVE 관린 GUI등이 포함, 
                                             //게이머의 데이터와 직접 통신하거나 게이머의 선택을 반영할 수 있는 API제공

using Microsoft.Xna.Framework.Graphics; // 3D오브젝트를 표시하는 하드웨어 가속 기능과 렌더링을 포함하는 낮은 수준의 응용프로그램 인터페이스를 제공

using Microsoft.Xna.Framework.Input; //xbox360 컨트롤러 장치와 키보드, 마우스의 입력을 받을 수 있는 함수와 클래스를 제공
using Microsoft.Xna.Framework.Input.Touch;
using Microsoft.Xna.Framework.Media; // 음악과 앨범, 재생목록, 사진 등의 자료 재생 및 접근과 관련된 클래스 제공

using Microsoft.Xna.Framework.Net;  // XNA프레임워크 게임상에서 Xbox Live 멀티 플레이어 지원 및 네트워킹을 구혀하는 클레스 제공

using Microsoft.Xna.Framework.Storage; // 저장장소의 파일을 읽고 쓰는 것을 담당하는 클래스를 제공



namespace WindowsPhoneGame2
{
    /// <summary>
    /// This is the main type for your game
    /// </summary>
    /// 
    public class Game1 : Microsoft.Xna.Framework.Game // 상속을 받았음.
    {
        GraphicsDeviceManager graphics; //그래픽디바이스매니저
        SpriteBatch spriteBatch; //이미지 출력시 다양한 옵션제공

        //SpriteFont spriteFont;
        //String messagetext = "Hello Windows Phone 7";

        Texture2D texture; //텍스처 
        


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

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

            graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight | DisplayOrientation.Portrait;
                                               //단말기 왼쪽이 밑변인 가로방향      단말기 오른쪽이 밑변인 가로 방향                   세로방향
            
            graphics.PreferredBackBufferWidth = 350;
            graphics.PreferredBackBufferHeight = 250;

            // 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(); //최상위에 있는 함수의 기능을 사용할떄 base.
        }

        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        /// 

        protected override void LoadContent() // 2D이미지 또는 3D 모델, 음원 등의 콘텐츠들을 게임 내에서 사용하기 위한 역할을 수행함.
        {


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

            //spriteFont = Content.Load<SpriteFont>("HelloFont");

            texture = new Texture2D(GraphicsDevice, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);
                                                                                            //그래픽 디바이스, 그래픽의 너비와 크기 지정
            texture = Content.Load<Texture2D>("exDog");  // 해당 2D 이미지 가져오기
            
            
        }

        /// <summary>
        /// UnloadContent will be called once per game and is the place to unload
        /// all content.
        /// </summary>
        /// 

        protected override void UnloadContent()  // LoadContent 메서드에서 로드한 콘텐츠들을 해제하는 역할을 게임 종료 또는 장치변경시 수행함.
        {
            // 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);//최상위에 있는 함수의 기능을 사용할떄 base.
        }

        /// <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) // 배경화면, 주인공 등 게임에 표현되는 2D 이미지와 3D모델, 텍스트 등을 화면에 출력하는 기능을 수행.
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            // TODO: Add your drawing code here

            //spriteBatch.Begin(); //일괄적으로 시작
           //spriteBatch.DrawString(spriteFont, messagetext, Vector2.Zero, Color.Black); //폰트적용, 메시지, 위치, 색
            //spriteBatch.End();


            spriteBatch.Begin(); // 출력시작

            spriteBatch.Draw(texture, new Vector2(0,0), Color.Red); //이미지 출력
           

            spriteBatch.End(); //이미지 출력완료

            base.Draw(gameTime); //최상위에 있는 함수의 기능을 사용할떄 base.
        }
    }
}




참고사이트

* MSDN Phone Page - http://msdn.microsoft.com/ko-kr/gg415576

* 서진호의윈도우폰이야기http://blogs.msdn.com/jinhoseo

* Windows Phone Korea –http://www.facebook.com/windowsphonekorea

*Windows Phone Training Kit- http://msdn.microsoft.com/en-us/hh220612 

'1. IT Story > Development' 카테고리의 다른 글

Heap Tree (보기좋게출력)  (0) 2012.03.28
하노이타워  (0) 2012.03.28
이진찾기  (0) 2012.03.28
피보나치  (0) 2012.03.28
C# 채팅 프로그램(Client 확장)  (0) 2012.03.07
C# 채팅 프로그램(Server 확장)  (4) 2012.03.07
C# 채팅 프로그램(Client)  (0) 2012.03.07
선택정렬응용  (0) 2012.03.07
블로그 이미지

운명을바꾸는자

IT와 함께 살아가는 삶

,