Code: Select all
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
namespace New2DRPG.CoreComponents
{
public class GameScreen : Microsoft.Xna.Framework.DrawableGameComponent
{
private List<GameComponent> childComponents;
public GameScreen(Game game)
: base(game)
{
childComponents = new List<GameComponent>();
Visible = false;
Enabled = false;
}
public List<GameComponent> Components
{
get { return childComponents; }
}
public override void Initialize()
{ base.Initialize();
}
public override void Update(GameTime gameTime)
{
foreach (GameComponent child in childComponents)
{
if (child.Enabled)
{
child.Update(gameTime);
}
}
base.Update(gameTime);
}
public override void Draw(GameTime gameTime)
{
foreach (GameComponent child in childComponents)
{
if ((child is DrawableGameComponent) &&
((DrawableGameComponent) child).Visible)
{
((DrawableGameComponent) child).Draw(gameTime);
}
}
base.Draw(gameTime);
}
public virtual void Show()
{
Visible = true;
Enabled = true;
}
public virtual void Hide()
{
Visible = false;
Enabled = false;
}
}
}
Code: Select all
function Show() {
'use strict';
var visible, enabled;
visible = true;
enabled = true;
}
Also this code was used as an example from the website tutorial on showing how to make a C# game with XNA. http://xnagpa.net/rpgtutorials.html