I'm iterating through shapes in a slide i.e <sld> xml. I'd like to get some properties (styling etc) from the corresponding shape in the slide_master (<sldMaster>) that the shape in the slide inherits properties from.
What is the key property that relates the two shapes? I'd assume this isn't simply an order-based relationship? i.e the nth shape in the slide master corresponds to the nth shape in the slide xml?
The discussion here seems to suggest that an order-based relationship is the only way? Get Layout Shape Corresponding to Slide Shape
Related
I need to create a SKSpriteNode or a SKShapeNode such that it would look like the image below. I can figure out how to use a texture to get the shape of the line but I can't seem to find a way to make the physics body. It needs to be made out of two horizontal lines which can change their y position and the middle parabola-like shape joins the other two lines with a specified maximum point (the maximum would hopefully be a variable).
(Note:- the blue and green lines are just to highlight that the image is compromised of three objects)
Is this possible? Thanks!
I would like to put the red dot before the numbers. I can do this by changing Z coordinates. But then the white area gets also located behind the red circle.
What am I doing wrong?
Thanks a lot.
Inside a canvas, if no override of sorting is taking effect the render sorting follows the sibling index in the hierarchy.
So if you want to order the objects like:
spectator -> white square -> red dot -> numbers
Just order them like this:
Canvas
...
000
red dot
white area
You can see that children that are lower in the hierarchy are rendered last ("closer" to the viewer).
This is true if all the children are UI elements, it won't work like this if mesh and sprite renderers are mixed with UI elements.
If it is the case, and if it is desired to be like this, I recommend you to read about sorting layers and overriding sorting layers of canvases.
Sorting Layer
Overriding Canvas sorting
I have a parent SKSpriteNode which contains a number of child SKShapeNodes, SKSpriteNodes and SKLabelNodes arranged in specific X,Y position relative to the parent.
When I flip the parent by running an SKAction on it:
SKAction.scaleXTo(-1, duration: duration)
It flips the parent including the children (which I want) but the horizontal alignment of all the children nodes is randomized.
I must mention that I have
parent.anchorPoint = CGPoint(x: 0,y: 0)
The reason this is happening is because of your anchor point. Scaling (And all transformations) happens on this point. To test, take a piece of paper, put a pencil on the top left corner, then try moving the right side over to the left. leaving the pencil where it is. You will notice that the right side is now -width of the paper
What you need to do in this case, is add the width back in to keep the paper at the same location.
Same rule with the sprites. You have to add the width in when doing a negative scale, then remove the width when going back to a positive scale
(or just put your anchor in the center)
Geometrical transformation you apply to a node are automatically applied to its descendants.
This is why when you move/rotate/scale a node the children (and the grandchildren...) are updated as well.
If you want apply a transformation to your sprite without involving other nodes simply change the structure of you scene moving the children of your sprite like shown below.
As it is now
In this image the green circle is your sprite. In the left scenario when you change the green node, it's children are updated accordingly. And you don't want that.
As it should be
So move to the right scenario. Create a new SKNode (the orange one) and place it as shown below.
Now the green node has no children so you can apply geometrical transformation to it without any side effect.
this question applies to any item but in this case I would like to position my image above the map, currently it gets place below the map.
I am new to swift 1.2 so I do not know how to put together an example, any help would be greatly appreciated.
Are you talking about above in X-Y terms or in Z terms? If Z terms, and using interface builder, you can go to editor->Arrange->Bring forward, or just move the image in the relation to the other UI elements, as their order in the below menu defines their Z-order.
Lets say I have the following game object hierarchy:
Board - The entire view of the game's board, made up of tiles.
Tile - A rectangular boundary within a board, made up of subtiles.
Subtile - A rectangular boundary within a tile.
A Board needs relative dimensions with respect to all of the contained Tile objects.
A Tile needs relative coordinates with respect to the containing Board.
A Subtile needs relative coordinates with respect to the containing Tile.
My current process is to define n Tile objects. Space them out x and y, such that x is the number of Subtile objects in a row and y is the number of Subtile objects in a column. Then, when I place Subtile objects, I just multiple the x or y by the containing Tile object's starting coordinate.
This process, so far, works well enough. However, to avoid complication and errors, I'd love to be able to simply lay out a Subtile object, where (0, 0) would be the top-left of the Tile object.
Without just abstracting my positioning a bit and adding classes for, say, SubtileVector or something, which would keep an additional variable for offset relative tile, is there an easier way to do this?
Likewise, when I want to see how big my board is and center my camera in the middle of it, I just end up calculating to that position. Is there any way to have my board always act as the containing box for these tiles, and be able to just do something like Board.Position.Center and get the exact center coordinates?
Yes there is. You can make a board game object, parent it to tile game objects, who on their turn are parent to subtile objects:
Board, parent to
Tile, parent to
Subtile
The good news is you can use the relative coordinates of tile and subtile using using their
transform.localPosition