Help with dealing cards - slide in effect (file attached)

I've worked on this for a few days and I've hit a mental wall. I want a deck of 52 cards to slide-in from the top of the screen. I am trying for an effect like a dealer is passing you a card and it is sliding into your view. I want each newly dealt card to stack on top of the previous cards. I am having problems setting up a spawner that will go through all 52 cards. When touch is pressed it must spawn a random card from my table and interpolate (slide-in) from off screen onto the screen. I also can't get the cards to stack since I am deleting the card's row.id from my table, hence eliminating the previously dealt cards. I hope this all makes sense. Any assistance with this file is greatly appreciated!!!

https://www.dropbox.com/sh/165lo5sl1vqgh1n/IF5rwJxJD8

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited January 2014
    I worked on this quite a bit but never finished the template. You can see my efforts here, along with @Socks' very nice demo: http://forums.gamesalad.com/discussion/54661/rotate-to-vertical-card-dealing.

    If your problem is that you are deleting rows from a table, why not use two tables (toDeal and Dealt)?

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • sawkasteesawkastee Member Posts: 184
    @tatiang very nice I'll take a look at this tonight.
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    You could have a master table that holds your 52 cards. when you need a new deck copy that table into another table which you can delete rows from without an issue.
    To get a card, store a random number between 1 and the number of rows left in the editable table. Pull that card from the table then delete the row at that index(the stored random number).
  • SocksSocks London, UK.Member Posts: 12,822
    edited January 2014
    @sawkastee

    I've made you a card-deal-from-the-top demo (hit the 'deal' button) - I've stuck a little randomness into the card's landing position and rotation (I think it adds a little realism).

    https://www.mediafire.com/?jw9j0cvm0l6bvn9

    . . .
  • sawkasteesawkastee Member Posts: 184
    @tatiang @CodeMonkey @Socks

    Ok so I'm using the card deal from the top demo. My cards dealt face up, I imported 52 card images. I created a master table (52 cards) and copy it to child table before I start removing rows from child table. I change an attribute self.row to random table row count of the child table when deal button is pressed. Card self image is equal to a row's ".png" of the child table. Issue I am having is getting the cards to stack when they are face up because I remove the tables row at self.row after I use it. How can I get the cards to stack on top of each other and keep the card image?
  • SocksSocks London, UK.Member Posts: 12,822
    edited January 2014
    @sawkastee
    Issue I am having is getting the cards to stack when they are face up . . .
    Is the fact that they are face up relevant here ? (GameSalad doesn't know whether they are face up or face down - or in fact whether they are potatoes).
    . . . because I remove the tables row at self.row after I use it. How can I get the cards to stack on top of each other and keep the card image?
    In what way does removing a row from the table effect the cards that have been spawned ?


    :-/
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    @sawkastee I take it you're changing the card actor's self.row and then constraining the self.image to an expression based on self.row. So when you remove a row from the table, it affects that expression. Instead of constraining self.image, you need to change it (change attribute).

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Sign In or Register to comment.