Jump to content


Photo

Turning card effect?


  • Please log in to reply
2 replies to this topic

#1 MonDieu

MonDieu

    GMC Member

  • GMC Member
  • 92 posts
  • Version:GM:Studio

Posted 18 April 2012 - 07:07 PM

I´ve made a memory match game and think a "turning card" effect would be nice.. anyone done this before? would appreciate some tips to start me off.
Thx :)
  • 0

#2 marsiic

marsiic

    GMC Member

  • GMC Member
  • 736 posts
  • Version:GM8

Posted 18 April 2012 - 07:22 PM

something like this!..

create
front=spr_card_01 //u can leave this out and change in step same value
turn=0

mouse left
if turn=3
exit
else
turn=1

step
if turn=1
{if image_xscale=0
{turn=2
sprite_index=front}
else
image_xscale-=0.1}
else
if turn=2
{if image_xscale=1
turn=3
else
image_xscale+=0.1}
  • 0

#3 PetzI

PetzI

    GMC Member

  • GMC Member
  • 1026 posts
  • Version:GM8.1

Posted 18 April 2012 - 07:37 PM

It's really simple, actually. You just need to mess with image_xscale or image_yscale. In the Create Event:

image_speed = 0 //Stops your sprite from scrolling through subimages automatically
time = 0

In the Step event:

image_xscale = cos(degtorad(time)) //In case you don't know, the cosine function returns a number from -1 to 1. Look it up for more info, it's very very useful-

//Resets the counter so that it doesn't get to very high numbers
if time >= 360
time -= 360
else
time += 2 //Change this number for different turning speeds. Make it negative for it to go the other way.

//Changes the sprite's subimage so it will show the two "faces" of the card
if image_xscale < 0
image_index = 1
else
image_index = 0

This code will make the card turn forever, but I hope from here you can take over and adapt it to your needs.

Edited by PetzI, 18 April 2012 - 07:39 PM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users