Pinch/zoom is a two-finger gesture in which if you place two fingers on the screen and bring the fingers closer, the image will be scaled down in size, and if you move the fingers apart, the image is enlarged.
For this, we need an image to work with; so, import the
Bg image from the first chapter to work with. Make the sprite a global variable as we will need to access it in another function.
So, in the
MainScene.h file, we will add an instance of
Also, we will add a global float called
currentScale to track the current scale value of the background image.
Next, in the
init function, we will initialize the variable, as follows:
backgroundImage = [CCSpritespriteWithImageNamed:@"Bg.png"]; ...