- Home /
two sided card that changes when flips
Hello guys!
I'm new to unity, and I want to make a simple card game. There is a card that flips on click, but on every click the card side changes to a shape (like: circle, triangle, square). My question is how I can define such a card? My idea is creating a sprite. and when I click on the sprite, it flips 180 degree. and on the degree 90, I change the sprite.
I don't know if there is a better way for that. When I Googled, there was something about prefabs.
Any Help would be appreciated. Thanks in advance.
Answer by winsjansen · Apr 08, 2015 at 09:23 AM
I assume since you are talking about sprites you want this to be a 2D game?
I'd say that since you'd want to change the actual shape of it and not just the image, changing at 90 degree is your best bet if you want to make the transition invisible.
I do suggest that you learn about Prefabs if you don't know anything about it, as it's the very core of most games, especially a card game. I promise you'll find tons of tutorials and more about the topic elsewhere so I'm not going to explain it here, but trust me you'll need it.
As for your problem I'd say just make an animation to rotate it 90 degrees, then in code just check for the animation to be complete and swap the sprite and play another animation that rotates another 90 degeees. (or you can just do it all in code and skip animations with something like Transform.Rotate)
If that doesn't give you the desired effect, let me know :)
Tanks a lot. And Yes, it is a 2D game. I think I'll have an empty card as a sprite, and import other cards with shapes on them as textures. then I change the empty card sprite's texture. right?
Yes, thats at least how I'd do it, let me know if you run into any problems and I'll try my best to continue to help out!
Your answer
Follow this Question
Related Questions
How to double spirte/gameobject/prefab and control the result on those items? 0 Answers
2D Animation Won't Allow Player To Move 0 Answers
How create a audience style game Rocksmith 1 Answer
Canvas image sprite change from script 0 Answers
Can I get the Cell X,Y from a sprite from a multi spritesheet? 0 Answers