Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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!

share|improve this question

2 Answers 2

up vote 3 down vote accepted

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)));
share|improve this answer
    
Beat me to it by a few seconds. –  Fibericon Aug 4 '12 at 8:52
    
Indeed, it was a matter of seconds lol :P –  David Gouveia Aug 4 '12 at 8:53
1  
Thanks! Since you was first, I accept your answer! –  3D-kreativ Aug 4 '12 at 9:03

Use a Vector2 object like this:

listJunk.Add(new Junk(content, "junk", new Vector2(x,y)));
share|improve this answer
1  
Thanks! I click useful anwer for you! –  3D-kreativ Aug 4 '12 at 9:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.