打造精彩 2D 游戏:从基础到进阶
1. 创建流星
创建流星组件的概念与创建玩家组件类似,不过流星的初始位置和移动依赖于随机因素。以下是流星的代码:
#region Using Statements
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
#endregion
namespace FirstGame
{
/// <summary>
/// This is a game component that implements the rocks the player must avoid.
/// </summary>
public class Meteor : Microsoft.Xna.Framework.DrawableGameComponent
{
protected Texture2D texture;
protected Rectangle spriteRectangle;
protected Vector2 position;
protected int Yspeed;
protected int Xspeed;
protected Random random;
// Width and
2D游戏开发进阶指南
超级会员免费看
订阅专栏 解锁全文
1169

被折叠的 条评论
为什么被折叠?



