Are you having separation anxiety? 😉
PD: I revised the texture and it is correct.
Does that mean that the problem no longer exists?
If you still have a problem, try using the width and height of the correct SPImages instead of the SPTexture. I believe the sizes SPImages could be different than SPTexture in some cases. (Although I am unsure why there would be a 0.5 pixel gap)
So for example, image4 would be something like this:
SPImage *imagen4 = [SPImage imageWithTexture:cuartoBoton];
imagen4.scaleX = -1;
imagen4.scaleY = -1;
imagen4.x = imagen4.width * 2;
imagen4.y = imagen4.height * 2;
[fondo addChild:imagen4];
Actually, after further evaluation of your code, the sure-fire way would be to align each image with the previous added image. Example:
- (SPSprite *) createBackgroundButton
{
SPSprite *fondo = [SPSprite sprite];
SPTexture *cuartoBoton = [self.atlasWizard textureByName:@"boton-opcion-uncuarto.png"];
// UP LEFT
SPImage *imagen1 = [SPImage imageWithTexture:cuartoBoton];
[fondo addChild:imagen1];
// UP RIGHT
SPImage *imagen2 = [SPImage imageWithTexture:cuartoBoton];
imagen2.scaleX = -1;
imagen2.x = imagen1.width+imagen2.width;
[fondo addChild:imagen2];
// DOWN LEFT
SPImage *imagen3 = [SPImage imageWithTexture:cuartoBoton];
imagen3.scaleY = -1;
imagen3.y = imagen1.height+imagen3.height;
[fondo addChild:imagen3];
// DOWN RIGHT
SPImage *imagen4 = [SPImage imageWithTexture:cuartoBoton];
imagen4.scaleX = -1;
imagen4.scaleY = -1;
imagen4.x = imagen3.width+imagen4.width;
imagen4.y = imagen2.height+imagen4.height;
[fondo addChild:imagen4];
return fondo;
}
Or if you want to slightly improve performance and you wont be changing the size of each image, this should work also:
- (SPSprite *) createBackgroundButton
{
float width;
float height;
SPSprite *fondo = [SPSprite sprite];
SPTexture *cuartoBoton = [self.atlasWizard textureByName:@"boton-opcion-uncuarto.png"];
// UP LEFT
SPImage *imagen1 = [SPImage imageWithTexture:cuartoBoton];
width = imagen1.width;
height = imagen1.height;
[fondo addChild:imagen1];
// UP RIGHT
SPImage *imagen2 = [SPImage imageWithTexture:cuartoBoton];
imagen2.scaleX = -1;
imagen2.x = width * 2;
imagen2.y = 0;
[fondo addChild:imagen2];
// DOWN LEFT
SPImage *imagen3 = [SPImage imageWithTexture:cuartoBoton];
imagen3.scaleY = -1;
imagen3.x = 0;
imagen3.y = height * 2;
[fondo addChild:imagen3];
// DOWN RIGHT
SPImage *imagen4 = [SPImage imageWithTexture:cuartoBoton];
imagen4.scaleX = -1;
imagen4.scaleY = -1;
imagen4.x = width * 2;
imagen4.y = height * 2;
[fondo addChild:imagen4];
return fondo;
}
If it still doesn't help, you can try rounding the values up or down so that the x/y values are all whole numbers instead of a decimal.