TMX: Only 1 tilset per layer is supported - cocoa-touch

i am take two layer Background and Cloud and in background i put background image and cloud layer i put cloud image and both TMX add to my project and when run i got error TMX: Only 1 tilset per layer is supported but only one layer use it run successfully..
Code:
CCTMXTiledMap *TiledFirst = [CCTMXTiledMap tiledMapWithTMXFile:#"BackgroundTiled.tmx"];
[self addChild:TiledFirst];
CCTMXTiledMap *Clould = [CCTMXTiledMap tiledMapWithTMXFile:#"Clould.tmx"];
[self addChild:Clould];

Cocos2d only supports one tileset per layer. This error occurs as soon as you add one tile (even a completely transparent one) from another tileset onto the same layer. Since there's no easy way to identify these tiles in Tiled and your map still being simple the easiest fix is to delete and re-add both layers, then make sure you add only tiles of one tileset to either layer.
PS: both KoboldTouch and Kobold Kit do not have this restriction.

Related

React Native Maps renders 2 background layers - blurred effect

I have a React Native application that contains a (react-native-maps) mapview with several different polylines and polygons created from http request data. The problem is that the map renders the background twice as you can see in the attached picture. This second layer is always a bit larger and more out of focus than the actual layer (the polygon/lines match with coordinaates on the clear defined layer). Im wondering how this second background came to be and how to prevent it from rendering.
Kind regards
Are you saying, that without providing an you are getting two layers?
Otherwise, when you use a different provider, for a layer and want to hide the layer provided by google, You should set mapType to "none".

Using Core Animation for a custom CATranstion

I would like to implement a new CATransition.
For example, let's say I would like to do this effect: a n by m array of two sided layers that have a portion of the source image on one side, and the a portion of the destination image on the other side. Each layer would rotate around its x axis by 180 degrees to reveal the other side. Can such a logic (animated CALayers) be used for a CATransition ?
I don't think you can do this. The only way to customize CATransition beyond the built-in types and subtypes, is by using a CIFilter(from iOS 5.0 or OSX 10.5). And the only way to create a custom CIFilter beyond chaining and configuring built-in filters is, according to the doc :
You can subclass CIFilter in order to create:
A filter by chaining together two or more built-in Core Image filters (iOS and OS X)
A custom filter that uses an image processing kernel that you write (OS X only)
So doing this based on CALayer animations is not possible.
On OSX this should be managable with some math work, but not directly using CALayers animations. In iOS this is simply not possible.
Instead of doing a CATransition you could achieve the same effect by using layers directly, but obviously it would not integrate as easily in your UI code.
I have written a transition effect like you describe, but it was not a CATransition. Instead, I created my own method to handle view transitions, and invoke that.
My transition cut the two views into vertical slices, and then did an animation where I start rotating the slices around their Y axes, starting with the left-most slice and working to the right, which creates a cool-looking cascade effect. It took quite a bit of work with CAAnimationGroup obbjects, plus using beginTime for each strip's animation to stagger it's beginning. That one transition animation took about 5 pages of code.

Preventing CALayer Sublayers From Getting Scaled

I have some CALayers in a layer hosted view. Each of these layers has additional layers to hold (1) a close button, and (2) a resize handle. These additional 'control' layers are added as sublayers to the parent layer.
Currently, when I zoom the workspace in which these layers reside, everything scales -- including these control layers. However, I would like to prevent these control layers from scaling.
Is there a way to override the behaviour of having scale transforms being applied to all sublayers, without having to override the drawInContext: method for each control layer (presumably to invert any existing scale transform -- assuming this is possible) and without having to manually send each of these control layers a setNeedsDisplay: with every zoom?
I found this thread which discusses doing something similar but the discussion goes in the direction of CATiledLayers which is not what I'm looking for here.
Redrawing CALayer subclass when super layer is scaled
Also, this post asks a somewhat related question but the responses do not apply to my situation, since I cannot overlay the controls -- they must be part of the layer hierarchy.
How do I keep a CALayer, sublayer of a CATiledLayer, from changing it's scale after a zoom?
I ended up solving this problem by overriding the layoutSublayers method of my custom CALayers, obtaining the accumulated scale transform of the layer hierarchy, and applying the inverse transform to the control sublayers.

Resizing CATiledLayer's Using Scale Transforms vs. Bounds Manipulation

I've got my layer hosted workspace working so that using CATiledLayers for hundreds of images works nicely when the workspace is zoomed out substantially. All the images use lower resolution representations, and my application is much more responsive when panning and zooming large numbers of images.
However, within my application I also provide the user the ability to resize layers with a resize handle. Before I converted image layers to use CATiledLayers I was doing layer resizes by manipulating the bounds of the image layer according to the resize delta (mouse drag), and it worked well. But now with CATiledLayers in place, this is causing CATiledLayers to get confused when I mix resizing of layers through bounds manipulation and zooming/unzooming the workspace through scale transforms.
Specifically, if I resize a CATiledLayer to half the width/height size (1/4 the area), the image inside it will suddenly scale to a further 1/2 the resized frame leaving 3/4 of the frame empty. This seems to be exactly when the inner CATiledLayer logic gets invoked to provide a lower resolution image representation. It works fine if I don't touch the resize handler and just zoom/unzoom the workspace.
Is there a way to make zooming/resizing play nice together with CATiledLayers, or am I going to have to convert my layer resize logic to use scale transforms instead of bounds manipulations?
I ended up solving this by converting my layer resize logic to use scale transforms by overriding the setBounds: method for my custom image layer class to scale it's containing CATiledLayer, and repositioning accordingly. Also it is important to make sure the CATiledLayer's autoresizingMask is set to kCALayerNotSizable since we are handling resizes manually in setBounds:.
Note: be sure to call the superclass's implementation of setBounds:.

Quartz 2D Layers

I want to create 2 separate layers using quartz 2D. Can i handle there redraw methods separately? so that i can redraw 1 layer without redrawing the whole screen or other layers.
Is it possible? any code sample?
Yes, it's possible and easy to do. Use the QuartzViewController/QuartzView classes in Apple's QuartzDemo iPhone sample code to get started. Use subclasses if you want specialized behavior.
See here:
http://developer.apple.com/IPhone/library/samplecode/QuartzDemo/Introduction/Intro.html
I'm coming from the Mac world. On the Mac, you'd create two overlapping views and deal with it that way. On the iPhone, I suspect you do the same: create two UIViews and then handle the two redraw methods independently. I believe overlapping views are fine on the iPhone (just as they are now on the Mac since 10.5).