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

'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?
Texture2D is way oversized in XNA 4.0?
How to set xna's TextureFilter to Point
Why doesnt my xna pixel shader turn this texture blue?

Categories

HOME
cakephp
mockito
reserved
plot
bookshelf.js
microservices
ebean
pivotal-cloud-foundry
uber-api
upload
multiple-records
node-notifier
session-variables
communication
quicklook
google-cloud-spanner
alignment
foselasticabundle
dbext
immutable.js
trading
selectedindexchanged
wpfdatagrid
kannel
entitlements
typo3-6.2.x
r-raster
galsim
uisplitview
jspresso
gtrendsr
stringtemplate
hybridauth
repo
http-referer
bower-install
plsql-psp
adobe-premiere
bitbucket-pipelines
x11-forwarding
twitch
gulp-sourcemaps
elmah
unixodbc
http-redirect
angular-resource
flickr-api
atomicity
pnotify
dotnetzip
veracode
feeds
lift-json
pillow
linode
chord-diagram
parallel-data-warehouse
rotativa
android-textview
google-web-starter-kit
essence
packagist
fadeout
rtbkit
thredds
atk4
coveralls
sframe
processmodel
nsight
cisco-ios
key-management
apache-commons-net
sorl-thumbnail
operator-precedence
rdtsc
document-classification
android-radiobutton
centos5
fmod
commoncrypto
gwt-rpc
django-nonrel
hungarian-algorithm
pygit2
enterprisedb
trusted
propertyeditor
automount
onsubmit
hirefire
servicehost
android-sdk-2.1
visitor-statistic
w3wp.exe
subviews
ti-dsp
port-number
putchar
ntvdm.exe

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App