xna-4.0


Lap timer in XNA 4.0?


Right, I've got a slight problem here, in which I've attempted to implement a lap timer.
In my protect override void update I've got this;
if ((IntersectPixels(destinationRedRect, car2redTextureData, startingLineRectangle, startingLineTextureData)))
{
{
redHit = true;
_timer1 += gameTime.ElapsedGameTime.TotalMilliseconds;
}
}
What I'm saying here^ is, if car2red is colliding with the starting line, the timer begins, but if it's not, timer does not add seconds (it just stops_ . How can I make it so, if car2red hits the startingLine and moves forward a few pixels (without touching starting line) the timer still continues?
Thank you.
You should have a separate if statement like this:
if (redHit) {
_timer1 += gameTime.ElapsedGameTime.TotalMilliseconds;
}
if ((IntersectPixels(destinationRedRect, car2redTextureData, startingLineRectangle, startingLineTextureData)))
{
redHit = true;
//Only use this line if you want to reset the timer to 0 when the player crosses that line again.
_timer1 = 0;// I'm assuming that _timer1 is a double
}

Related Links

XNA choosing a subgroup of Game.Components
Loading Silverlight Texture2D from Resources
XNA Game - Open a Popup or a Custom Game Screen before launching a game
'Microsoft.Xna.Framework.Vector2' is a 'type' but is used like a variable?
Making a trading card game XNA
How do I fix 'No suitable method found to override' error on XNA 4.0?
When to use PresentationParameters.BackBufferWidth vs .Viewport.Width
What does the pixel shader function tex1D do with a Texture2d
How to add a lap timer in XNA?
Is there a Texture1D in XNA?
Particle System: XNA Framework HiDef profile does not support alpha blending on Vector4 textures
How to unset texture data in XNA 4.0
Detecting a Key Press in XNA 4.0?
How to add a start (splash) screen in XNA 4.0?
My program is being reported as a high-level security threat by AVG?
How to add an end screen in XNA 4.0?

Categories

HOME
cakephp
yii2
ionic-framework
ngrx
infragistics
v8
retrofit
node-pdfkit
google-cloud-ml
amazonsellercentral
wkwebview
firebase-crash-reporting
smb
numerical-methods
spark-jobserver
django-storage
windowbuilder
libssl
madlib
media-queries
iframe-resizer
semantic-versioning
airconsole
wallpaper
wixsharp
plsql-psp
occlusion
starteam
twitch
lumberjack
fedex
gzipstream
quadratic-programming
vao
apple-news
appcompat
strptime
komodoedit
errordocument
jquery-validate
promela
fancybox-2
mu
media-player
epson
color-profile
query-performance
nested-sets
parallel-data-warehouse
android-textview
probability-density
sts-springsourcetoolsuite
url-masking
etsy
gridview-sorting
actionbardrawertoggle
asp.net5
two-factor-authentication
cloudbees
srand
thredds
angular-leaflet-directive
splash
event-bubbling
graph-drawing
sailfish-os
system32
truevault
directoryservices
google-style-guide
ceil
reactfx
hippomocks
app42
html5-notifications
cdc
tws
pushbackinputstream
datawindow
twrequest
hosts-file
wse3.0
netdna-api
vdsp
html-input
routedevent
web-architecture
brewmp
sustainable-pace
nerddinner

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App