Welcome! Log In Create A New Profile

Advanced

sprite setPosition dilema

Posted by g_man 
sprite setPosition dilema
May 05, 2010 07:59AM
Ok, i'm sure my problem is pretty easy, but what am I doing wrong. I'm trying to set the location of circles on a 2D plane, but I have to have different sized circles. I already have the code for changing the sizes setup, but I'm having trouble placing them in the correct location on the screen.
Here is the code that should place the center of the circle in the position entered:
for(i=0;i<levelList[lvlnum].numPlanets;i++){	//For every planet that exists
		planets.SetImage(&planet1img);																//Set the image
		planets.SetRefPixelPosition(0,0);
		planets.SetZoom((float)levelList[lvlnum].planetR/50);											//Set the zoom 
		planets.SetPosition(levelList[lvlnum].planetX-levelList[lvlnum].planetR,levelList[lvlnum].planetY-levelList[lvlnum].planetR);	//Set the position
		manager.Append(&planets);																	//Add to the layer manager
	}
planetX, and planetY are supposed to be the center of the circle, and planetR is the radius. The original radius is 50, and what the SetPosition line does is take the X value, which would place by the top left, and subtracting the radius from both the X and the Y values, which in theory would place it in the correct location.
any help is appriciated
Re: sprite setPosition dilema
May 05, 2010 02:31PM
nevermind...



Edited 1 time(s). Last edit at 05/05/2010 02:32PM by mdbrim.
Re: sprite setPosition dilema
May 08, 2010 09:10PM
Ok, I think I could figure it out if I got the position that the planets were actually being drawn to. Is there a way to get the number of pixels away from the center a sprite is. Right now I am using 320-getX(), which doesn't work because the sprite is technically being displayed at 320,240.
Re: sprite setPosition dilema(SOLVED)
May 10, 2010 05:14AM
Ok I figured it out, dophin wasn't displaying the location of the sprites right, but it works fine on the wii.



Edited 1 time(s). Last edit at 05/11/2010 06:25AM by g_man.
Sorry, only registered users may post in this forum.

Click here to login