0
\$\begingroup\$

In the first code I get a Vector2 random position and create an object with that, but in the second code I want to use the same constructor to create an object, but I want to pass a X and Y value to the constructor, that expects a Vector2 value.

Vector2 newPosition = NewRandomPosition;    
listTools.Add(new Tool(content, tools[i], newPosition));

I thought I could do something like this, but it didn't work!

int x = 30, y = 22;
listJunk.Add(new Junk(content, "junk", (x,y)));

Is there another way to do this? Thanks!

\$\endgroup\$

2 Answers 2

3
\$\begingroup\$

You need to create a Vector2 from the x and y values before using it. For example:

listJunk.Add(new Junk(content, "junk", new Vector2(x,y)));
\$\endgroup\$
2
  • \$\begingroup\$ Beat me to it by a few seconds. \$\endgroup\$
    – Fibericon
    Aug 4, 2012 at 8:52
  • \$\begingroup\$ Indeed, it was a matter of seconds lol :P \$\endgroup\$ Aug 4, 2012 at 8:53
3
\$\begingroup\$

Use a Vector2 object like this:

listJunk.Add(new Junk(content, "junk", new Vector2(x,y)));
\$\endgroup\$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .