Hi again, I'm having a problem with my level editor.
The program is supposed to scale the pictures in a matrix down to 100px using the formula:
scale = 100.f / texture.getsize().x
This works great for when the program is opened but when i try to change folders I get a wierd bug.
First run:
When I click another folder:
The code used to scale the pictures and to calculate the position
// If the texture is greater than 100px on the Y axis
if(menu_obj_texture[i].getSize().y > 100 && menu_obj[i].getScale().y == 1)
{
// Set the scale according to the y axis
scale = 100.f / menu_obj_texture[i].getSize().y;
// If the width of the obj is still greater than 100px
if(menu_obj_texture[i].getSize().x * scale > 100)
{
// Set the scale according to the x axis
scale = 100.f / menu_obj_texture[i].getSize().x;
}
cout << "scale : " << scale << endl;
// Scale the object accordingly
menu_obj[i].setScale(scale, scale);
}
// Else if the texture is greater than 100px on the X axis
else if(menu_obj_texture[i].getSize().x > 100 && menu_obj[i].getScale().x == 1)
{
// Set the scale according to the x axis
scale = 100.f / menu_obj_texture[i].getSize().x;
// if the height of the obj is still greater than 100px
if(menu_obj_texture[i].getSize().y * scale > 100)
{
// Set the scale according to the y axis
scale = 100.f / menu_obj_texture[i].getSize().y;
}
cout << "scale : " << scale << endl;
// Scale the object accordingly
menu_obj[i].setScale(scale, scale);
}
// Set the position according to x and y
menu_obj_bg[i].setPosition((125 * x) + 2.5, (y * 125) + 2.5);
// Calculate the x position by using the size of the texture multiplied by the scale divided by two
menu_obj[i].setPosition(menu_obj_bg[i].getPosition().x +((125 - menu_obj_texture[i].getSize().x * menu_obj[i].getScale().x) / 2),
// Calculate the y position by using the size of the texture multiplied by the scale divided by two
menu_obj_bg[i].getPosition().y + ((125 - menu_obj_texture[i].getSize().y * menu_obj[i].getScale().y) / 2));
Thanks in advance.