Click here to Skip to main content
15,867,835 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

Hi, I managed to compile a poker game in visual studio in which to animate the dealing of cards I used a timer in the designer. Alas, in XNA this doesnt seem to be an option (as far as im aware).


When I run this all cards appear on screen at the same time, not very realistic.


How do I create a timer to draw the cards at seperate intervals?


C#
//playercard contains card images

Texture2D[] playercard = new Texture2D[4];
SpriteBatch[] playcard = new SpriteBatch[4];
{
    GraphicsDevice.Clear(
    spriteBatch.Begin(
    {
        playcard[i].Begin(
    }
    {
        playcard[i].Draw(playercard[i],
        cardposition = cardposition + 100;
    }
    cardposition = 550;
    {
        playcard[i].Draw(playercard[i],
        cardposition = cardposition + 100;
    }
    for (int i = 0; i < 2; i++)
        new Vector2(cardposition, 50), Color.White);
    for (int i = 2; i < 4; i++)
        new Vector2(cardposition, 300), Color.White);
    protected override void Draw(GameTime gameTime)
    Color.CornflowerBlue);
    SpriteBlendMode.AlphaBlend);
    for (int i = 0; i < 4; i++)
        SpriteBlendMode.AlphaBlend);
Posted
Updated 17-Jul-10 23:53pm
v3
Comments
DaveyM69 18-Jul-10 5:55am    
I have edited your post as the code was totally illegible. Now it's properly formatted it's not much better due to many glaring errors. If you are going to paste code, at least make sure it compiles!

1 solution

You don't need the designer to add a timer, in fact adding one in the designer is kind of ridiculous.  I can't see any reason why you can't use a timer in XNA, I just expect you need to create it in code.

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900