How do I flip a card?

0 favourites
  • 3 posts
From the Asset Store
Goodbye to sprite fonts, when you have something new on the anvil for your upcoming Games !
  • Currently C3 already supports Mesh. Is there a new solution now?

    construct.net/en/forum/construct-3/how-do-i-8/flip-card-143331

    quote:

    Hello guys,

    does anoyone knows how to create a flipping card effect?

    Thanks

    Ashley 3 years ago:

    Not at the moment, because any non-flat 3D features allows for depth intersection, which requires a depth buffer, which doesn't normally work with an alpha channel... so it ends up opening a whole can of worms.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Well there is a depth buffer, and transparency does mostly work in 3D. Not always though.

    You can rotate the corners with a bit of math. It’s just a matter of applying them to a distort mesh.

    One idea place four sprites at

    -32,-48

    32,-48

    32,48

    -32,48

    These will serve as our points. Give them three instance variables z, Newx and newz.

    then you can rotate them with:

    var a=0
    var sa=0
    var ca=0
    
    every tick:
    — set a to time*10
    — set sa to sin(a)
    — set ca to cos(a)
    -- sprite: set newx to self.x*ca-self.z*sa
    -- sprite: set newz to self.x*sa-self.z*ca
    
    every tick
    — card: set size to (1,1)
    -- card: set distort mesh to 2,2
    -- set distort at 0,0 to card.x+sprite(0).newx, card.+sprite(0).y, 32+sprite(0).newz, -1,-1
    -- do the same for the other points: 
    0,1 with sprite(1)
    1,1 with sprite(2)
    1,0 with sprite(3)

    sorry i trailed off with the bit where you set the distort points. generally youd have card have a size of 1,1 and place the points with absolute. Unless something changed you can’t use a negative z for a distort point, so you’d need to shift things a bit higher.

  • Here's a simplified single object, one instance variable version.

    dropbox.com/s/6qs81zmktsd3so8/yaxis_rotate.c3p

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)