Home >Web Front-end >JS Tutorial >Creating a Simple Windows 8 Game with JavaScript: Windows 8 App Basics
This tutorial guides you through building a simple Windows 8 game using HTML5, JavaScript, WinJS, and CreateJS libraries, adapting the XNA sample "Catapult Wars Lab".
Key Concepts Covered:
Project Setup and Structure:
Begin by installing Windows 8 and Visual Studio 2012. Create a new JavaScript "Blank App" project in Visual Studio, naming it "CatapultGame". The project's key components include:
References/Windows Library for JavaScript
(WinJS): Provides JavaScript and CSS for Windows 8 app development.css/default.css
: Starter CSS, including media queries for responsive design.js/default.js
: Contains initial JavaScript logic; this is where the game's core functionality will reside.default.html
: The main HTML page for the game.package.appxmanifest
: Project settings (name, description, etc.).images
folder: Contains default images; replace these with your game assets.Running the empty project reveals a basic HTML page with "Content goes here" text. This text originates from the default.html
file.
HTML, CSS, and JavaScript Roles:
default.html
): Defines the game's structure and content.default.css
): Styles the game's appearance and handles responsive layout using media queries for different screen orientations and window sizes.default.js
): Manages game logic, handles user input, updates game state, loads assets, and renders the game on the canvas. The onactivated
and oncheckpoint
functions in default.js
are crucial for initialization and saving game state before suspension, respectively.Next Steps and Further Learning:
The following posts will detail the game's development, integrating assets from "Catapult Wars Lab" and building the game's core mechanics. For more advanced examples, refer to the MSDN JavaScript and HTML5 touch game sample. The tutorial emphasizes simplicity; more comprehensive game development techniques are available in the suggested further reading.
The above is the detailed content of Creating a Simple Windows 8 Game with JavaScript: Windows 8 App Basics. For more information, please follow other related articles on the PHP Chinese website!