游戏开发框架:性能优化与基础游戏实现
1. 项目对象初始化
在开发游戏时,对象的初始化是重要的一步。以下是 OrbitingSprites 项目中对象初始化的代码:
protected override void LoadContent()
{
PlanetObject planet;
MoonObject moon;
// Create a new SpriteBatch, which can be used to draw textures.
_spriteBatch = new SpriteBatch(GraphicsDevice);
Textures.Add("Planet", Content.Load<Texture2D>("Planet"));
Textures.Add("Moon", Content.Load<Texture2D>("Moon"));
// Add a planet...
planet = new PlanetObject(this, new Vector2(150, 200),
Textures["Planet"], 0.7f);
GameObjects.Add(planet);
// ...and give it a moon
GameObjects.Add(new MoonObject(this, Textures["Moon"],
planet, 0.02f, 60, 0.3f, Color.White));
//
超级会员免费看
订阅专栏 解锁全文
167万+

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



