What is the simplest way to make the cards trail? (SOLVED)

solitaire-for-windows
First my idea was a remove render.clear, but result is strange:

Maybe somebody know how to this? Thanks.

Draw to a buffer?

Looks like problem you have in your image is that real cards are still being drawn on top. You need to maybe disable card drawing until they cascade away?

2 Likes

Ah, I think that is due to the double buffering… But you should be able to do it by rendering to a texture/render target instead (ie. and removing the render.clear call when you want that effect).

@Pkeod was faster than me! :smiley:

2 Likes

@Pkeod @sven Thank you!
I am bad in OpenGL things. (
Ok, i’ll try. Maybe you know examples with something that can help me?

I know how to make it in theory, I made this things using other technology. In most cases it’s about drawing sprite into bitmapdata(texture) many times.
But I don’t know how to make it in Defold.

for example phaser (one method for drawing sprite into bitmapdata) https://phaser.io/examples/v2/bitmapdata/draw-sprite

Hmm, I was thinking it would be easier to use a particle effect (with a very long life time), but they draw in the opposite order of what you want.

So here’s a quick little demo project doing it with a render target that you don’t clear. I copied most of the render script from another project, so it has a bunch of extra stuff in there to refresh the render target if you change the window size (which won’t work for your purpose), but hopefully it gives you the general idea.

Render Target Cards.zip (42.6 KB)

cards_RT

A bunch of the render target code I originally got from of this thread: Draw render target to screen (SOLVED)

10 Likes

Wow! Thank you very much!
hug

7 Likes

Your example helped me to understand how its works. Now this puzzle assembled in my head.
Turns out it’s easy =)
One more big thanks!

5 Likes

Awesome, glad to help!

Yeah, it’s easy, though my example was overly-complicated. Basically just:

  1. Set view and projection as you would normally
  2. Enable render target
    2.5. Normally—render.clear(), In this case skip it to make trail effect.
  3. Draw stuff
  4. Disable render target
  5. Set view and projection so quad model for render target fills the screen
  6. Enable render target texture
  7. Draw render target quad model
  8. Disable render target texture

(for anyone reading in the future)

7 Likes