Cocos2d - Should I use ccDrawLine or OpenGL for touchable "lines" - opengl-es

I'm working on an iOS game, and part of it requires the player to be able to touch and interact with some lines that are drawn on the screen. Essentially, I need to be able to detect whether or not a player has touched a line, and if so, change it's color/thickness etc.
Now, I know I can overwrite the draw method on a custom class with ccDrawLine and render out the line. Is that preferable to using OpenGL to render them?
Thanks

Sure, it is preferable, because cocos2d takes care of content scaling. I suggest you take a look at ccDrawLine function inside CCDrawingPrimitives.m.

Related

Animating a Clip-Path in React-Native View

Basically I have an opaque View covering a screen, and I want to build an animation that is something like a (perfect circular) hole in the view forming in the center (so to reveal whats underneath) and expanding outwards.
I'm thinking that there could be a few creative ways to get this done, and that perhaps the most corresponding CSS property to play with would be 'clip-path'. If that is the case, I don't believe ReactNative Views offer that, and 3rd party libraries w/ SVG & clipping features seem like they wouldn't play well with Animating the effect.
Any ideas much appreciated!
You could use https://github.com/react-native-community/react-native-svg !
The library supports SVG's better and allows you to animate with Clip-path!

Animate UIView as flipboard in iOS

I tried to use MPFoldTransition for my UIView animation. But I want it like flipboard. That is, it should be animated as per the user touch.
Please help me that how can I achieve it. Also, is there any other library for UIView animation like flipboard.
If you want to use a library for this flip, MPFlipViewController uses MPFoldTransition and works with a pan gesture.
Also, take a look at https://github.com/ITechRoof/ITRFlipper
If you want to build this yourself and have a true flip like Flipboard (where it flips in the middle, with appropriate shadows), taking a snapshot of the view and using a simple matrix transform can do the trick. I'm not going to go into all the details as I could talk for hours about animation timing and shadows.

Xcode image/pixel manipulation realtime

Hi I'm looking to do the following:
For a game, Create some effects based on the current view.
The code needs to grab part of a view then manipulate it.
One I need is "glass", so when the character walks behind the glass(or where the glass should be), the code will grab the image behind the glass and stretch it and reprint it where the glass should be, to give the effect of walking behind a lens.
What is the best way to do this?
I've never tried any thing like this before, so any help will be great!
I think you're asking about the image manipulation capabilities of the cocoa framework, in which case I reccomend looking into CoreImage:
http://developer.apple.com/library/mac/#documentation/graphicsimaging/Conceptual/CoreImaging/ci_intro/ci_intro.html#//apple_ref/doc/uid/TP30001185
The NSBox draws on top of the player view, the resulting composition gets a CIFilter (distortion) applied to it before drawing.

Cocoa control to render a tile map

Is there any Cocoa control that is capable of drawing tile maps with multiple layers and multiple texture sources which can also intercept touches into single tiles? Having multiple layer support is not a real requirement but an optional feature (the views could still be stacked). Hardware acceleration is not needed at all.
So far I have toyed around with NSMatrix, IKImageBrowser and NSCollectionView but non of them felt like a good solution for the problem. Ideally I need an control similar to the one in Tiled.app. Is there anything, third party or built-in, or do I have to handcraft this control?
I fear that you will be hardly able to find a ready-to-use control for managing tile maps.
If I had to implement something like that on my own, I would consider using CATiledLayer, since this is the closest thing to a tile map control that I know of.
From CATiledLayer Reference:
CATiledLayer is a subclass of CALayer providing a way to asynchronously provide tiles of the layer's content, potentially cached at multiple levels of detail.
There is a nice sample by Bill Dudney (the author of "Core Animation for MacOS and the iPhone"). This sample could provide you a solid foundation for your own project, though it only displays one single PDF, allowing you to zoom in the area you clicked on (this requires rereading the tile at a different detail level).
Another interesting introduction can be found here. This is more step-by-step, so you might start with this.
Finally, on Cocoa is my Girlfriend there is a nice article, although it focuses on iOS, but you may find it anyway relevant.
Cocos2D supports building mac applications now
Article on cocos2d stating this: http://www.cocos2d-iphone.org/archives/1444
Aee here for how to do it: http://chris-fletcher.com/tag/cocos2d-os-x/
Aee here on how to use TMX tile maps with Cocos2D to build tile based maps: http://www.cocos2d-iphone.org/wiki/doku.php/prog_guide:tiled_maps
This means you can use the power of Cocos2d and you will have to write much less code to get to where you want with a tile based map.
If you don't want to use Cocos2D:
It seems you would have to code it yourself, but it shouldn't be too hard to do.
First you can create your .TMX file using the tile editor "Tiled.app" then you would need to parse the XML using a standard xml library for Cocoa.
To lay out the tiles use a UIView for the overall container and then create a tile class that holds your tile display information and responds to clicks the tile class should extend UIView. For the tile class allow the assigning of a click delegate and assign your ViewController as the click delegate for all tiles so you can handle clicks easily with the clicked tile being passed to you.
Loop through your xml data and create and position the tiles in the overall UIView by using the tiles width/height and your tilemaps rows/columns.
I think in about a day or 2 you could have the tile map being rendered and clickable using the standard TMX format which will allow you to edit your map in "Tiled.app"
The TMX standard is covered here: https://github.com/bjorn/tiled/wiki/TMX-Map-Format
route-me might fit the bill.

Cocoa draw noise

Is it possible to draw some noise on top of a rect I filled using NSRectFill? I need to make my app that draws a custom title bar look wonderful on 10.7 before release, and to make it look a little more like iTunes. I would love if this is possible using no images, but if I have to include a PNG or something as a mask, I'd be fine with that.
Thanks!
You can either use drawing logic (drawing a lot of small rects, lines or other polygons), or use NSImage's drawing methods, like for instance: drawInRect:fromRect:operation:fraction:

Resources