GML How to make a card flip effect?

Discussion in 'Programming' started by CombatCalamity, Oct 11, 2019.

  1. CombatCalamity

    CombatCalamity Member

    Joined:
    Feb 16, 2019
    Posts:
    67
    I want to make it exactly like this



    Thanks.
     
  2. Toque

    Toque Member

    Joined:
    May 25, 2017
    Posts:
    1,047
    Google “gamemaker card flip effect”

    Its been asked and answered a few times in the past.

    that would be a good start. You could try previous suggestions first.

    hope that helps.
     
  3. CombatCalamity

    CombatCalamity Member

    Joined:
    Feb 16, 2019
    Posts:
    67
    Can you simply link the exact result that you meant here? Because I couldn't find exactly this. Surely it wouldn't be that much to ask for since it's been answered a few times in the past, right?

    Also, yes, I have scoured the surface myself before doing a last resort which is to ask here.

    All the results from google search first page are non gamemaker specific, and if it is, its answers vaguely direct me to learn matrix and 3D stuff which I have no interest in. I simply ask for a quick and fast way to have a flipping card effect.
     
  4. Toque

    Toque Member

    Joined:
    May 25, 2017
    Posts:
    1,047
    Sorry I don’t know how to code this myself.
    I would try it with a sprite animation. (Because I cant code it). Make it quick. Wouldn’t be perfect though.

    I might try playing with sprite animation and x_scale.

    There probably a way to do it with GML.

    it does seem like they play with 3D in the posts. Maybe someone can help with that............
     
  5. Coded Games

    Coded Games Member

    Joined:
    Jun 20, 2016
    Posts:
    413
    The steps for the easy way to do it:

    1. Make object with card back sprite.
    2. Gradually decrease image_xscale
    3. When image_xscale == 0, change to card front sprite.
    4. Gradually increase image_xscale back to 1.
     
    Cloaked Games likes this.
  6. CombatCalamity

    CombatCalamity Member

    Joined:
    Feb 16, 2019
    Posts:
    67
    That's not what I want at all. It will look like this instead.
    https://twitter.com/soulweavergames/status/798292630790606848

    Now compare that to => https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_flip_card

    Quite a difference, right?
     
  7. GameDevDan

    GameDevDan Get Gyro Boss DX Moderator GMC Elder

    Joined:
    Apr 21, 2016
    Posts:
    194
    It's not much of a difference. It depends how difficult you want it to be to code.

    Making image_xscale go from 1 to -1 and changing the sprite at 0 is the fast, easy way of doing it and it's a passable effect.

    To achieve the effect in the CSS example where it turns through a 3d angle so that the card image skews slightly, you would have to do one of the following things:
    • Make your game in d3d
    • Use draw_sprite_pos and do some clever calculations
    • Draw a primitive from scratch using some clever calculations
     
  8. The Reverend

    The Reverend Member

    Joined:
    Sep 8, 2016
    Posts:
    553
    CombatCalamity likes this.
  9. CombatCalamity

    CombatCalamity Member

    Joined:
    Feb 16, 2019
    Posts:
    67
    Unfortunately number 2 doesn't work that easily and it's the most viable option compared to the other 2. It has some weird behavior that stretches the sprite randomly.

    Ahhh crap, this is exactly what I'm looking for, thanks so much @The Reverend !!!!
     
    The Reverend likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice