how to swap images using Cocoa Touch - iphone

I am trying to build 15-puzzle game.
Here I need to swap a blank image with a clicked on image. I would like to know how to swap these images.
I have stored the co-ordinates of the two images,but don't know the format to identify the blank image and then set its origin to clicked image.

Present each tile as a CALayer. To swap two tiles, set each layer's position to the other's position.

Related

Unity scrollview inherit scale and keep position relative to parent

I'm trying to add some buttons to a gameObject which is a scroll view child. The child is a very wide image, about 4 times as wide as normal screens, which is why I let it control the height, so that it is always from top to bottom, and only exeeds horizontally where scroll is allowed.
Here you can see my setting.
1. is the wide image
2. is a banner that used to be part of the image, but now I want it to be a individual gameObject.
I don't know how I can make the banner (2) inherit the behavior of the "full map" (1), right now when I choose free aspect and resized the game view, the "full map" scales nicely, so the it always fits from top to bottem. The more narrow the screen is, then more of the map will exceed to the right, and vice versa.
However the problem is that then banner (2) has a rect transform, which is set with x,y coordinates relative to the parent which scales. So as i resize around the view, the banner gets out of it's intended position, and also does not scale with the. I have tried many different components, but without luck. Here among, scale constraint, canvas scaler, position constraint
As you can see in this gif, the banner does not scale down, as the island gets smaller, also it stays in the same position horizontally.
Any suggestions on how I can make the children os the map behave as they were part of the map?
Deleted previous, misunderstood the question.
Proposed solution:
You remove the map part from UI and create it as an object: You attach the map image as a texture to (ie) a plane (see a video here). You add the "infinity island" as another texture and have it placed over the island image.
After that, you control the camera to zoom in/out of the island and not struggle with any scaling or moving UI.
I think you need to anchor the images to center of the island mini image, you can drag the anchor gizmo from the scene hierarchy.
If you see it as free aspect it gets buggy and difficult to handle, but if you choose a resolution everything is smooth.
Is this what you want?
Change the resolultion

Create Mosaic on image

In image app i have to blur the selected areas of image. Something like create mosaic at selected area of image. i have to get each pixel color of selected area and then increase the size of each pixel. here is the reference link that i am using http://soulwithmobiletechnology.blogspot.in/2011/05/create-mosaic-with-your-image-part-1.html . But not able to implement this practically for selected area. Can any one have some sample for the same.
There are two solutions for this
1. Get the screen shot of the area where you want the mosaic effect and apply effect to the same portion. Then add the image(with mosaic effect) to the original image.
2.Get the pixel of the area you want to be effected and then gave effect to those pixels.*

How can I create a tile, overlay for a scene in Cocos2d?

I'm new to Cocos2d, but I can't seem to find the answer to this. I want to add an image that is mostly transparent as an overlay to my application. The image is overlayed on the app, and does not respond to screen taps. All gestures should "pass through" to the application.
The overlay image should actually be tiled. It's a small image that should repeat both horizontally and vertically.
How can I do this? In fact, this is an overlay that I would like to display for the duration of the entire application-- not just one specific scene. Is there a simple way to do this?
The point of my overlay is that I'd like to create a pseudo-scan line affect for a game which has an "8-bit" tone. The scan lines will be generated by applying the overlay to the game. The overlay is non-interactive and should always exist. So, this isn't a "tile based game", but I do need a tiling affect for this functionality.
You should be able to create a layer in each scene, set the zOrder to something large so that it overlays everything else, and set its isTouchEnabled attribute to NO. You can then add whatever you want to the layer, which could be your patterned image. To change the alpha, just set the opacity attribute of your image. The only issue that I can foresee is that the overlay might disable touch events for layers below it.

How to make a hole in an image iphone

I have a game that players place their pieces on the screen then press set. I am using cocos 2d to build the iphone app. It is kind of like hide and seek. I then overlay a background on top of all of that. I want to be able to tap on the screen and create a hole in my background at that spot so that I can see through it. I know I can just create a giant image with a hole in it and move it around, but my background can only be a color it can't be an image. How should I go about doing this.
Instead of trying to see "through" the overlay, place the "background" image on top in circles. Map the screen coordinates on top of the "background" image, then extract a circular region from that image to place on the screen. The biggest challenge would be capturing a circular region from your bitmap. I'm not too familiar with cocos2d, but there should be a library you can use for it.

What class is used in this iphone app

I've been long time searching for a way to achieve placing pins on an image just like the mapview, but have not been able to do this yet. I thought someone could give a clue as what kind of class is used in this picture.As you can see everything is like MKMapView with Annotation pins and callout except for that it's not a map but an ordinary image. How can I achive the same thing?
Yeah, basically a matter of creating the pin image, then placing image views of that image over your background image. Create the image view, set it's position as needed, and call addSubview from the background image.
You can try a simple way, first find out the position of the user tap on the image or screen. Then place that pin image on that tap position in such a manner the height of the pin image should point the y axis of the tap. If you want to store that data then store it in some array or file and you can also save that image (the map containing pins) as png.