Click here to Skip to main content
15,891,567 members
Home / Discussions / C#
   

C#

 
AnswerRe: how to ... Pin
Bernhard Hiller16-Sep-12 23:37
Bernhard Hiller16-Sep-12 23:37 
AnswerRe: how to ... Pin
Shameel17-Sep-12 0:06
professionalShameel17-Sep-12 0:06 
QuestionDataGridView throwing Drawing exception when assigning datasource Pin
Groulien16-Sep-12 6:42
Groulien16-Sep-12 6:42 
QuestionRe: DataGridView throwing Drawing exception when assigning datasource Pin
Eddy Vluggen16-Sep-12 14:58
professionalEddy Vluggen16-Sep-12 14:58 
AnswerRe: DataGridView throwing Drawing exception when assigning datasource Pin
Groulien18-Sep-12 5:33
Groulien18-Sep-12 5:33 
GeneralRe: DataGridView throwing Drawing exception when assigning datasource Pin
Eddy Vluggen18-Sep-12 8:12
professionalEddy Vluggen18-Sep-12 8:12 
QuestionC# work with documents Pin
rachel_m16-Sep-12 5:54
rachel_m16-Sep-12 5:54 
AnswerRe: C# work with documents Pin
Richard Andrew x6416-Sep-12 7:22
professionalRichard Andrew x6416-Sep-12 7:22 
GeneralRe: C# work with documents Pin
rachel_m16-Sep-12 13:52
rachel_m16-Sep-12 13:52 
GeneralRe: C# work with documents Pin
Eddy Vluggen16-Sep-12 14:31
professionalEddy Vluggen16-Sep-12 14:31 
QuestionLooking for low-level C# Projects Examples Pin
atoi_powered16-Sep-12 4:55
atoi_powered16-Sep-12 4:55 
AnswerRe: Looking for low-level C# Projects Examples Pin
Paul Conrad16-Sep-12 5:48
professionalPaul Conrad16-Sep-12 5:48 
GeneralRe: Looking for low-level C# Projects Examples Pin
atoi_powered16-Sep-12 10:49
atoi_powered16-Sep-12 10:49 
GeneralRe: Looking for low-level C# Projects Examples Pin
Paul Conrad16-Sep-12 11:21
professionalPaul Conrad16-Sep-12 11:21 
GeneralRe: Looking for low-level C# Projects Examples Pin
atoi_powered18-Sep-12 23:22
atoi_powered18-Sep-12 23:22 
GeneralRe: Looking for low-level C# Projects Examples Pin
Paul Conrad19-Sep-12 5:36
professionalPaul Conrad19-Sep-12 5:36 
AnswerRe: Looking for low-level C# Projects Examples Pin
Richard MacCutchan16-Sep-12 5:58
mveRichard MacCutchan16-Sep-12 5:58 
GeneralRe: Looking for low-level C# Projects Examples Pin
atoi_powered16-Sep-12 10:56
atoi_powered16-Sep-12 10:56 
GeneralRe: Looking for low-level C# Projects Examples Pin
Richard MacCutchan16-Sep-12 21:01
mveRichard MacCutchan16-Sep-12 21:01 
QuestionData compression Pin
Mubi, Nigeria16-Sep-12 2:04
Mubi, Nigeria16-Sep-12 2:04 
AnswerRe: Data compression Pin
Pete O'Hanlon16-Sep-12 2:07
mvePete O'Hanlon16-Sep-12 2:07 
GeneralRe: Data compression Pin
harold aptroot16-Sep-12 2:08
harold aptroot16-Sep-12 2:08 
AnswerRe: Data compression Pin
cmk16-Sep-12 8:37
cmk16-Sep-12 8:37 
QuestionXNA Sprite Frame Inconsistency Pin
Sasstraliss15-Sep-12 19:46
Sasstraliss15-Sep-12 19:46 
I have an explosion sprite, with 16 frames.


Everytime the player collides with an asteroid, the gamestate is set to loseScreen, and when the loseScreen is the gamestate, the lose() function is continually called until the gamestate changes.

Inside the lose() function, this code draws the animated spritesheet, which runs through the 16 frame animation. It should always start from frame 0, but it doesn't always. Sometimes it starts at frame 10, and only runs for 6 frames before finishing. That's the issue. The code inside the lose() function to draw the explosion animation is as follows:


C#
expFrameID = 0;
expFrameID += (int)(time * expFPS) % expFrameCount;
Rectangle expRect = new Rectangle(expFrameID * expFrameWidth, 0, 63, 63);
spriteBatch.Draw(explosion, shipLocation, expRect, Color.White, 0f, new Vector2(32, 32), 1.0f, pickupSpriteEffects, 0.1f);
if (expFrameID == 15)
    expIsDrawn = true;



The time variable is as follows, it gets the total elapsed game time.

C#
time = (float)gameTime.TotalGameTime.TotalSeconds;


I've tried changing TotalGameTime to ElapsedGameTime, nothing changed.
It's the following line from the lose() function that I believe is the issue, perhaps:

C#
expFrameID += (int)(time * expFPS) % expFrameCount;


It works, and it animates. However it doesn't always start at frame 0. it starts from random frames between 0 and 16, but it still runs correctly at 16 frames per second.

So, how do I get it to always start from frame 0?


Would I solve my issue by making a new time variable that starts a timer from 0 only when the lose() function is called? How do I do that?
QuestionC# working with xml Pin
rachel_m14-Sep-12 20:49
rachel_m14-Sep-12 20:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.