Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SpriteKit - get absolute size of SKNode

I'm programming a small game in Swift and SpriteKit, which is made of a boxes (4 * 8).

Scene (1024 * 768)
    boxes (964 * 452)
        row1 (932 * 25)
            col1 (24 * 116)
            col2 (24 * 116)
            col3 (24 * 116)
            ...
        row2...

I want to give them a texture, but I don't know how big the image file should be. And the box node's size seems to be relative to its parent node. How can I get the absolute size of an SKNode, the size the node takes on the screen?

like image 645
SpilledMango Avatar asked Jul 05 '17 06:07

SpilledMango


1 Answers

All SKNodes have a method called calculateAccumulatedFrame

like image 157
Knight0fDragon Avatar answered Dec 16 '22 03:12

Knight0fDragon