Hii there..
I am creating a game window 7 mobile phone....I am getting troubled in this section.
ninjaStar = new NinjaStar(10, spriteSheet, new Rectangle(0, 0, 50, 50),
20,
this.window.ClientBounds.Width,
this.window.ClientBounds.Height,
level1.Player);
its showws that Error 1 'NinjaPlatform.NinjaStar' does not contain a constructor that takes 6 arguments ....
Highly appreciated if any hint.
6 Replies - 307 Views - Last Post: 19 June 2012 - 06:35 AM
#1
XNA 4.0: does not contain a constructor that takes 6 arguments
Posted 18 June 2012 - 11:51 PM
Replies To: XNA 4.0: does not contain a constructor that takes 6 arguments
#2
Re: XNA 4.0: does not contain a constructor that takes 6 arguments
Posted 19 June 2012 - 01:16 AM
Please post your ninja star class.
#3
Re: XNA 4.0: does not contain a constructor that takes 6 arguments
Posted 19 June 2012 - 01:36 AM
stayscrisp, on 19 June 2012 - 01:16 AM, said:
Please post your ninja star class.
here is the whole bunch of code for the ninjastar class.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace NinjaPlatform
{
class NinjaStar
{
private int screenWidth = 800;
private int screenHeight = 600;
private int screenPadding = 10;
private Rectangle initialFrame;
private int starFrames;
private Texture2D texture;
public List<Sprite> Stars = new List<Sprite>();
private int minSpeed = 50;
private int maxSpeed = 100;
public Player player;
private Random rand = new Random();
public void AddStars()
{
Sprite newStars = new Sprite(
new Vector2(-500, -500),
texture,
initialFrame,
Vector2.Zero);
for (int x = 1; x < starFrames; x++)
{
newStars.AddFrame(new Rectangle(
initialFrame.X + (initialFrame.Width * x),
initialFrame.Y,
initialFrame.Width,
initialFrame.Height));
}
newStars.Rotation =
MathHelper.ToRadians((float)rand.Next(0, 360));
newStars.CollisionRadius = 15;
Stars.Add(newStars);
}
public void Clear()
{
Stars.Clear();
}
public NinjaStar(
int starCount,
Texture2D texture,
Rectangle initialFrame,
int starFrames,
int screenWidth,
int screenHeight,
Player activePlayer) //CONSTRUCTOR CHANGE
{
this.texture = texture;
this.initialFrame = initialFrame;
this.starFrames = starFrames;
this.screenWidth = screenWidth;
this.screenHeight = screenHeight;
for (int x = 0; x < starCount; x++)
{
AddStars();
}
player = activePlayer; //REFERENCE TO THE PLAYER
}
private Vector2 randomLocation()
{
Vector2 location = Vector2.Zero;
bool locationOK = true;
int tryCount = 0;
do
{
locationOK = true;
switch (rand.Next(0, 3))
{
case 0:
location.X = -initialFrame.Width;
location.Y = rand.Next(0, screenHeight);
break;
case 1:
location.X = screenWidth;
location.Y = rand.Next(0, screenHeight);
break;
case 2:
location.X = rand.Next(0, screenWidth);
location.Y = -initialFrame.Height;
break;
}
foreach (Sprite stars in Stars)
{
if (stars.IsBoxColliding(
new Rectangle(
(int)location.X,
(int)location.Y,
initialFrame.Width,
initialFrame.Height)))
{
locationOK = false;
}
}
tryCount++;
if ((tryCount > 5) && locationOK == false)
{
location = new Vector2(-500, -500);
locationOK = true;
}
} while (locationOK == false);
return location;
}
private Vector2 randomVelocity()
{
Vector2 velocity = new Vector2(
rand.Next(0, 101) - 50,
rand.Next(0, 101) - 50);
velocity.Normalize();
velocity *= rand.Next(minSpeed, maxSpeed);
return velocity;
}
private bool isOnScreen(Sprite stars)
{
if (stars.Destination.Intersects(
new Rectangle(
-screenPadding,
-screenPadding,
screenWidth + screenPadding,
screenHeight + screenPadding)
)
)
{
return true;
}
else
{
return false;
}
}
private void BounceStars(Sprite stars1, Sprite stars2)
{
{
Vector2 cOfMass = (stars1.Velocity +
stars2.Velocity) / 2;
Vector2 normal1 = stars2.Center - stars1.Center;
normal1.Normalize();
Vector2 normal2 = stars1.Center - stars2.Center;
normal2.Normalize();
stars1.Velocity -= cOfMass;
stars1.Velocity =
Vector2.Reflect(stars1.Velocity, normal1);
stars1.Velocity += cOfMass;
stars2.Velocity -= cOfMass;
stars2.Velocity =
Vector2.Reflect(stars2.Velocity, normal2);
stars2.Velocity += cOfMass;
}
}
public override void Update(GameTime gameTime)
{
foreach (Sprite stars in Stars)
{
stars.Update(gameTime);
if (!isOnScreen(stars))
{
stars.Location = randomLocation();
//FOLLOW THE PLAYER
//stars.Velocity = new Vector2(player.Position.X - stars.location.X, player.Position.Y - stars.location.Y).Normalize(); Velocity = Vector2.Multiply(Velocity, Speed);
}
}
for (int x = 0; x < Stars.Count; x++)
{
for (int y = x + 1; y < Stars.Count; y++)
{
if (Stars[x].IsCircleColliding(
Stars[y].Center, Stars[y].CollisionRadius))
{
BounceStars(Stars[x], Stars[y]);
}
}
}
}
public void Draw(SpriteBatch spriteBatch)
{
foreach (Sprite stars in Stars)
{
stars.Draw(spriteBatch);
}
}
}
}
#4
Re: XNA 4.0: does not contain a constructor that takes 6 arguments
Posted 19 June 2012 - 01:42 AM
Your ninjastar class has 7 arguments for its constructor but you are only providing it with 6.
#5
Re: XNA 4.0: does not contain a constructor that takes 6 arguments
Posted 19 June 2012 - 02:24 AM
Actually he is providing it with 7
ninjaStar = new NinjaStar(10, spriteSheet, new Rectangle(0, 0, 50, 50), 20, this.window.ClientBounds.Width, this.window.ClientBounds.Height, level1.Player);
#6
Re: XNA 4.0: does not contain a constructor that takes 6 arguments
Posted 19 June 2012 - 02:26 AM
yes...its 7......
#7
Re: XNA 4.0: does not contain a constructor that takes 6 arguments
Posted 19 June 2012 - 06:35 AM
This should be in the XNA section since it's an XNA question.
From what I can see, you've got the proper amount of arguments as well as the proper values on the arguments. Let me see the entire code that contains the declarations and instantiation of the NinjaStar objects.
From what I can see, you've got the proper amount of arguments as well as the proper values on the arguments. Let me see the entire code that contains the declarations and instantiation of the NinjaStar objects.
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote







|