public LightningSprite(Texture2D texture, SoundEffect sound, Vector2 position, CloudSprite[] clouds, LightningGame game) : base(texture, position) { myGame = game; myTexture = texture; mySound = sound; myClouds = clouds; myState = new IdleState(this); }
public override void LoadContent(ContentLoader content) { Texture2D lightTx = content.Load<Texture2D>("Lightning"); int lightX = (graphics.GraphicsDevice.Viewport.Width - lightTx.Width <= 0 ? 100 : ((graphics.GraphicsDevice.Viewport.Width - lightTx.Width + 100) / 2)); Texture2D introTx = content.Load<Texture2D>("intro2"); int introX = (graphics.GraphicsDevice.Viewport.Width - introTx.Width <= 0 ? 0 : ((graphics.GraphicsDevice.Viewport.Width - introTx.Width)/2)); int introY = (graphics.GraphicsDevice.Viewport.Height - introTx.Height <= 0 ? 0 : ((graphics.GraphicsDevice.Viewport.Height - introTx.Height) / 2)); myIntro = new IntroSprite(introTx, new Vector2(0, 0), new Vector2(graphics.GraphicsDevice.Viewport.Width, graphics.GraphicsDevice.Viewport.Height)); for (int i = 0; i < myClouds.Length; i++) { myClouds[i] = new CloudSprite(content.Load<Texture2D>("cloudX"), new Vector2(-i*300, 0), i); mySprites.Add(myClouds[i]); } myLightning = new LightningSprite(lightTx, content.Load<SoundEffect>("lightningS"), new Vector2(lightX, 0), myClouds, this); mySprites.Add(myIntro); mySprites.Add(myLightning); spriteBatch = new SpriteBatch(GraphicsDevice); }