Triangle, with 3 levels, containing text on iOS - ios

I need some advice with my current project. The big problem being, I'm an android dev, helping out on iOS for the next few days.
I need to create a triangle, with 3 levels of text (as seen in the image below). Just adding labels at the different levels is leaving me with a lot of unused space. I have also though of using CGMutablePathRef to create a triangle, but it doesn't seem I can add a label to it, like you can to a CALayer. Or am I missing something?
Please, any advice would be appreciated (and example code even more so, as my iOS skills are still quite shocking).
Regards

Related

Distribute Elements of different sizes with a uniform gap between them in After Effects

I've been looking for a solution to this problem for a long time. Maybe someone has a tip for me. The Problem is also mentioned in the official adobe help, but without a solution.
Adobe Help writes:
"When you distribute layers of different sizes, the spaces between layers may not be uniform. For example, distributing layers by their centers creates equal space between the centers—but different-sized layers extend by different amounts into the space between layers."
Here is a graphic that shows what I want to have in AE. The first and last elements are only half visible.
Atm i do that in sketch (Distribute Layers horizontally), import it in illustrator and pick the x-values and enter it manual in AE. Thats insane, maybe there is better solution ;-)

Creating text / number objects in ARKit

I want to create some objects (boxes, cylinders, pyramids, doesnt really matter) which display text / a number on the side / on all of it's sides. Short of making individual materials with the numbers displayed on them by hand, is there a simple way to achieve this?
I am using Swift 4 in XCode.
First thing, please try not to be discouraged. Thank you for reaching out to the ARKit community on stack :-)
We are here to help each other.
(I do feel your pain…and why I am trying to help)
Here is an interesting stack page that has helped me with placing items on the sides of objects(like boxes cylinders, pyramids).
I hope it can help you or others.
SCNBox different colour or texture on each face
Rickster pointed out some other possibilities.
We all learn by sharing what we know.
Smartdog
Depends on what you mean by "by hand". If you want the text displayed on the surface of the geometry, like a texture map, then texture-mapping it is the way to go. If you draw your text into a UIImage, you can set that as the material contents, which is a bit more dynamic than, say, creating a bunch of PNGs that each have a different number on them. Just make sure to choose an image size/resolution that looks good at the size your objects are displayed at.
For anyone lost in the internet trying to find an answer to this it's stupidly simple. Use SCNText and set it as a node. I just wasted 7 hours of my life trying to make number .dae models position themselves next to each other because there is no mention of this feature anywhere.
I hope I saved you as much pain as I just endured discovering this.

Stage3D iOS Antialiasing on AIR 24

With AIR 24 release we are able to set anti aliasing on Stage3D now, but there are some issues with it. Can anybody help how to use it in right way without changing entire project code ?
The issue I have is that anti alias works great, and no more jagged edges, but there are rendering issues and I guess some texture normals are being inverted, also when using Occlusion Material there are some jagged material shadows...
Next thing I notice is when drawing Wireframe Globe with Lines Segments - the lines are visible on the globe all the time, no matter if you add some object in front or not.
So, intersecting line segments with other materials don't work at all, and lines are on the screen forever.
Please, help if you find any trick fixing the issues.
Thanks
Just to add some more information: the issue seems to happen when shareContext = true. Without Starling there is antialiasing and the lineSegments are rendered at the current depth. It would be interesting to see if it works with other sharedContext besides Starling to isolate the issue. If I find an answer I will come back and post it. It would be nice to get this working. Any idea the performance hit on mobile of having a second instance of away3d? Layering that way might be a dirty work around.
*****EDIT****
AntiAliasing on the line Segments only occurs with sharedContext. View3D class does not seem to have it's antiAlias value set anywhere and when I forced it to a value of 2, all hell broke loose.
Edit#2
Mesh appears above line segments, Sprite3D do not.

Memory Usage of SKSpriteNodes

I'm making a tile-based adventure game in iOS. Currently my level data is stored in a 100x100 array. I'm considering two approaches for displaying my level data. The easiest approach would be to make an SKSpriteNode for each tile. However, I'm wondering if an iOS device has enough memory for 10,000 nodes. If not I can always create and delete nodes from the level data as needed.
I know this is meant to work with Tiled, but the code in there might help you optimize what you are looking to do. I have done my best to optimize for big maps like the one you are making. The big thing to look at is more so how you are creating textures I know that has been a big killer in the past.
Swift
https://github.com/SpriteKitAlliance/SKATiledMap
Object-C
https://github.com/SpriteKitAlliance/SKAToolKit
Both are designed to load in a JSON string too so there is a chance you could still generate random maps without having to use the Tiled Editor as long as you match the expected format.
Also you may want to consider looking at how culling works in the Objective-C version as we found more recently removing nodes from the parent has really optimized performance on iOS 9.
Hopefully you find some of that helpful and if you have any questions feel free to email me.
Edit
Another option would be to look at Object Pooling. The core concept is to create only sprites you need to display and when you are done store them in a collection of sorts. When you need a new sprite you ask the collection for one and if it doesn't have one you create a new one.
For example you need a grass tile and you ask for one and it doesn't have one that has been already created that is waiting to be used so it creates one. You may do this to fill a 9 x 7 grid to fill up your screen. As you move away grass that gets moved off screen gets tossed into the collection to be used again when the new row comes in and needs grass. This works really well if all you are doing is displaying tiles. Not so great if tiles have dynamic properties that need to be updated and are unique in nature.
Here is a great link even if it is for Unity =)
https://unity3d.com/learn/tutorials/modules/beginner/live-training-archive/object-pooling

How to check intersection of two images that aren't rectangular?

New user to the site, but I have used it in the past so I felt it best to ask my question here, for the best chance of getting a response.
What I'm dealing with is one object, this being the sprite for my latest app, which I need to check for when it comes in to contact with another object, in this case, a tunnel which will curve.
Now, I'm aware of CGRectIntersectsRect, however I can't see that being helpful, as if I've got 2 UIImages, that being the top and bottom of a "mountain", and said pieces curving, there's no doubt that the sprite would touch the "rectangle".
What I need is something to trigger when the sprite hits the actual wall, however my limited knowledge of Objective-C isn't helping my case.
I imagine someone out there will know what I can do to resolve this, as for all I know it could be a simple solution.
Thank you in advance everyone!
First, I'd probably not build these basic pieces yourself. For iOS 7, you can use SpriteKit, which is built-in. If you want to support older versions of iOS, look at cocos2d (it's good for iOS 7, too).
But to the question, one approach for detecting arbitrary overlaps is to draw both objects into a buffer and check if there are any overlapping pixels (for instance, by drawing one in in pure red, and another in pure green, and then looking for pixels that have both). For a discussion of how to do this kind of thing in Core Graphics, see Clipping a CGRect to a CGPath, which provides sample code for the simplest version (checking for the intersection of a rectangle and curve), but the same approach can be used more generally. Note that this drawing can get expensive if you're doing it constantly, so usually you first check whether the bounding rectangles overlap. That tells you whether it's even worth the trouble to look closer.
But first I'd look at SpriteKit.

Resources