Divide player?

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 😂

Replies

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.

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 😬

And the Player is a spriteNode yes c:

Thanks for additional info. But still many things being unclear.

Please notice that showing your code speak more than hundreds of words. Please show all relevant codes.

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
}

Oh thank you! Now i get the principe 😁

Yes i‘ll add a Couple things and write again when sth is Not clear. Thank you 😁

Don't forget to mark the thread as closed it that answered your question.


And don't hesitate to post a new question if needed if you have issue with your code.


Good luck.