public void Init(Rectangle gameBounds, Vector2 pos) { base.Init(gameBounds); gameManager = GameManager.Instance; bananas = new List<Banana>(); for(int i = 0; i<3; i++) { Banana b = new Banana(bananaSize,Direction.Left); b.texture = gameManager.ResourceManager.RetreiveTexture(ResourceManager.BANANA_SCORE_PATH); b.Init(gameManager.GameBounds); b.Origin = new Vector2(bananaSize.Width/2, bananaSize.Height/2); b.position = pos; b.position.X += r.Next(30)-15; b.position.Y += r.Next(30)-15; b.Rotation = (float)r.NextDouble() * 3; b.SpriteEffects = r.Next(2) == 0 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; bananas.Add(b); } }
public Banana CreateRandomBanana(Leaf leaf) { Banana banana = new Banana(leaf.Direction); GameManager gameManager = GameManager.Instance; banana.texture = gameManager.ResourceManager.RetreiveTexture(ResourceManager.BANANA_PATH); banana.Init(gameManager.GameBounds); banana.position.X = leaf.Direction == Direction.Left ? leaf.position.X - 30 + leaf.FrameSize.Width - 30 : leaf.position.X + 30; banana.position.Y -= 10; // to position the banana directly on the leave banana.SpriteEffects = leaf.SpriteEffects; return banana; }