1. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

GM:S 1.4 [SOLVED] Animating a card flipping

Discussion in 'Programming' started by Matt93, Apr 14, 2017.

  1. Matt93

    Matt93 Guest

    Hey everyone,

    I'm making a Solitaire game at the moment, and am trying to add in some smooth animations. If possible, I'd like the card which you select from the deck to be animated flipping over as it's revealed. Something similar to this:

    I can't even think how I would do this, or whether I should aim to do this with code, or use a program (if so, which?) which could make the animation frames for me. Any advice would be great.

    Cheers!
     
  2. obscene

    obscene Member

    Joined:
    Jun 21, 2016
    Posts:
    2,460
    d3d_transform_set_rotation_y(some_value_here); // Gradually change this from 0 to 180 and you might get the effect you want
    d3d_transform_add_translation(x,y,0);
    draw_self();
    d3d_transform_set_identity();

    If you don't care about the perspective you can simply manipulate image_xscale to flip things in a flat 2D way.
     
  3. Matt93

    Matt93 Guest

    Thank you! I had no idea about these functions. Just to check, would I need to use all those d3d_ functions you just listed? And would I need to adapt those translation values where you've written d3d_transform_add_translation(x,y,0)? I'm going to experiment with this tomorrow anyway.
     
  4. obscene

    obscene Member

    Joined:
    Jun 21, 2016
    Posts:
    2,460
    Use it just as it's written, you only need to change the first line.
     
  5. zendraw

    zendraw Member

    Joined:
    Jun 20, 2016
    Posts:
    1,376
    why dont you use draw_sprite_pos.
     
  6. Matt93

    Matt93 Guest

    I got it working using the d3d functions! Here's my code:

    Draw event:
    Code:
    d3d_transform_set_rotation_y(val);
    d3d_transform_add_translation(x,y,0);
    draw_sprite(sprite_index,image_index,0,0);
    d3d_transform_set_identity();
    Then just increasing val in the step event until it reaches 180. Thank you for the help, marking as solved.
     
    obscene likes this.
  7. mfd_famous

    mfd_famous Guest

    So it seems these functions are not available by default in GMS2? Does anybody know how I could use these functions for an otherwise 2D card game in GMS2?
     
  8. TheSly

    TheSly Member

    Joined:
    Jan 16, 2017
    Posts:
    1,000

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