มาหัดใช้ Game State Management III
posted on 06 Jan 2008 12:02 by xnanoob in Tutorials
สวัสดีค่า
วันนี้เรามาต่อกับการเพิ่มด่านของเราเองนะค่ะ
ก้อสร้าง new class ขึ้นมาปกติโดยที่ Inherit จาก GameScreen เท่านั้นเอง ดังนี้
| class MyGame : GameScreen
{
} |
|
ContentManager content; Texture2D Img;public override void LoadContent() { if (content == null)content = new ContentManager(ScreenManager.Game.Services, "Content");Img = content.Load< Texture2D>(@"Actor/TerraFront");
} public override void UnloadContent(){ content.Unload(); } public override void Update(GameTime gameTime, bool otherScreenHasFocus,bool coveredByOtherScreen){ } public override void Draw(GameTime gameTime){ SpriteBatch spriteBatch = ScreenManager.SpriteBatch;spriteBatch.Begin(); spriteBatch.Draw(Img, Vector2.Zero, Color.White);spriteBatch.End(); } |
โดยที่เขียน Mygame เสร็จแล้วก้อสามารถไปเพิ่มได้โดยแสดงดังรูป ผูก event แล้วไปเรียก class
เมื่อเกิดการกดเมนู
จบแระค่ะ บายค่ะ
งุงิ งุงิ
edit @ 6 Jan 2008 14:30:31 by xnanoob








ถ้าปิดเทอมลองไปสมัครฝึกงานเขียนเกมส์ที่
www.secondsoft.co.th สิครับ
#1 By เอกน้อย on 2008-01-06 15:48