sprite zoom problem April 14, 2010 05:08AM | Registered: 15 years ago Posts: 444 |
for(i=0;i<levelList[lvlnum].numPlanets;i++){ //For every planet that exists planets.SetImage(&planet1img); //Set the image planets.SetZoom(levelList[lvlnum].planetR/50); //Set the zoom planets.SetPosition(levelList[lvlnum].planetX-50,levelList[lvlnum].planetY - 50); //Set the position manager.Append(&planets); //Add to the layer manager }What I did was my original planet has a radius of 50, so took the new planet radius and devided it by 50. This gives me a ratio of planet sizes, which libwiisprite uses.
Re: sprite zoom problem April 14, 2010 06:09AM | Registered: 14 years ago Posts: 121 |
Re: sprite zoom problem April 14, 2010 06:49AM | Registered: 15 years ago Posts: 444 |
Re: sprite zoom problem April 14, 2010 09:20AM | Registered: 14 years ago Posts: 40 |
planets.SetZoom(levelList[lvlnum].planetR / 50f);
Re: sprite zoom problem April 14, 2010 11:30AM | Registered: 14 years ago Posts: 121 |
Re: sprite zoom problem April 14, 2010 12:15PM | Registered: 14 years ago Posts: 379 |
Good compilers will still complain about an implicit cast.Quote
calvinss4
Hi there g_man. How long have you been programming in C? According to your Level struct, levelList[lvlnum].planetR is an integer. When you divide an integer by an integer (i.e. levelList[lvlnum].planetR/50), it carries out integer arithmetic, meaning only the integer part of the result is kept. So for example, 49/50 = 0.98 = 0.
If you want to carry out floating point division, then at least one of the numbers must be of floating point type. Try the following:planets.SetZoom(levelList[lvlnum].planetR / 50f);
Oh but wait, some of these antiquated compilers will complain; you may need to write 50.0f instead of 50f.
planets.SetZoom(float(levelList[lvlnum].planetR) / 50.0f);
Re: sprite zoom problem April 14, 2010 03:17PM | Registered: 15 years ago Posts: 444 |