8 Replies
      Latest reply on Apr 18, 2019 12:35 PM by Claude31
      TonneDzn Level 1 Level 1 (0 points)

        Hey, i want a Player object; grey and orange. (Orange underneath grey) now this Player should fall and React to bars in grey or orange (so obviously when orange Hits a grey bar or other way round: Game Over) Now i wondered How to have one Falling object which two sites reacting different to the barriers? Sorry for my Bad english

        • Re: Divide player?
          OOPer Level 7 Level 7 (4,875 points)

          Please clarify what you want to do. I do not think your english is so bad, but even in textbook-like goooood english, explaining something like yours with only usual statements can easily be unclear.

           

          You should better include some code when you ask something about coding.

           

          For example what is your Player object? Is it a subclass of SKSpriteNode, or something else? If you show your current definition of `Player`, that may work better than hundreds words of explanation.

           

          And you have `bars` in your scene. You also say something about `barriers`. Are you referring to the same thing? Or your Falling object means Player?

           

          Please clarify all such things. Showing your code (even if it may be incomplete) may help.

            • Re: Divide player?
              TonneDzn Level 1 Level 1 (0 points)

              Ok sry, so the Player is an object which just falls down. On the Screen should randomly spawn barriers. With a tap you can turn the Player (so either the orange side is underneath the grey or grey underneath orange) Now if grey „touches“ grey or if orange „touches“ orange nothing Happens so the Player object just falls through. There Should only be a collision between orange & grey. I searched a lot on all this but i didnt find a way to „Combine“ these actions so i Started and Started again all the Time. So it is more a question in general How to do all this

                • Re: Divide player?
                  TonneDzn Level 1 Level 1 (0 points)

                  And the Player is a spriteNode yes c:

                  • Re: Divide player?
                    Claude31 Level 8 Level 8 (5,645 points)

                    What is it you don't know how to do ?

                     

                    Do you know how to animate objects ?

                    Do you know how to detect a collision ?

                    If not, search for the many tutorials for Spritekit.

                     

                    If so, what remains is to detect the nature of collision.

                     

                    You could define in your player class a property

                    var upsideIsOrange: Bool // true if orange at top, false otherwise

                     

                    then, in the collision, you test with the following logic:

                    if barrier is orange and upsideIsOrange {
                         // then bottom is grey, that's a crash
                         game over
                    }
                    
                    if barrier is grey and upsideIsOrange is false {
                         // then bottom is orange, that's a crash
                         game over
                    }