mirror of
https://github.com/thes3m/XNI
synced 2024-12-26 13:26:06 +01:00
Enabled multitouch and corrected fixed timestep reporting.
git-svn-id: http://xni.googlecode.com/svn/XNI@40 ac433895-eea3-a490-d80a-17149a75e588
This commit is contained in:
parent
de457cb4e2
commit
14d015cfbb
@ -88,6 +88,8 @@
|
||||
// Save the loaded asset for quick retreival.
|
||||
[loadedAssets setObject:result forKey:assetName];
|
||||
|
||||
[input release];
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -116,17 +116,19 @@ NSArray *drawOrderSort;
|
||||
NSTimeInterval elapsedRealTime = [currentFrameTime timeIntervalSinceDate:lastFrameTime];
|
||||
|
||||
// Sleep if we're ahead of the target elapsed time.
|
||||
if (isFixedTimeStep && elapsedRealTime < targetElapsedTime) {
|
||||
NSTimeInterval sleepTime = targetElapsedTime - elapsedRealTime;
|
||||
CFRunLoopRunInMode(kCFRunLoopDefaultMode, sleepTime, NO);
|
||||
|
||||
// Recalculate elapsed times.
|
||||
[currentFrameTime release];
|
||||
currentFrameTime = [[NSDate alloc] init];
|
||||
elapsedRealTime = [currentFrameTime timeIntervalSinceDate:lastFrameTime];
|
||||
gameTime.isRunningSlowly = NO;
|
||||
} else {
|
||||
gameTime.isRunningSlowly = YES;
|
||||
if (isFixedTimeStep) {
|
||||
if (elapsedRealTime < targetElapsedTime) {
|
||||
NSTimeInterval sleepTime = targetElapsedTime - elapsedRealTime;
|
||||
CFRunLoopRunInMode(kCFRunLoopDefaultMode, sleepTime, NO);
|
||||
|
||||
// Recalculate elapsed times.
|
||||
[currentFrameTime release];
|
||||
currentFrameTime = [[NSDate alloc] init];
|
||||
elapsedRealTime = [currentFrameTime timeIntervalSinceDate:lastFrameTime];
|
||||
gameTime.isRunningSlowly = NO;
|
||||
} else {
|
||||
gameTime.isRunningSlowly = YES;
|
||||
}
|
||||
}
|
||||
|
||||
// Store current time for next frame.
|
||||
@ -140,7 +142,7 @@ NSArray *drawOrderSort;
|
||||
gameTime.totalGameTime += elapsedGameTime;
|
||||
|
||||
// Update input.
|
||||
[[TouchPanel instance] update];
|
||||
[[TouchPanel getInstance] update];
|
||||
|
||||
// Update the game.
|
||||
[self updateWithGameTime:gameTime];
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
- (id) init {
|
||||
if (self = [super init]) {
|
||||
services = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
|
||||
services = CFDictionaryCreateMutable(NULL, 0, NULL, &kCFTypeDictionaryValueCallBacks);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -23,6 +23,8 @@
|
||||
eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSNumber numberWithBool:NO], kEAGLDrawablePropertyRetainedBacking,
|
||||
kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil];
|
||||
|
||||
self.multipleTouchEnabled = YES;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -78,9 +78,10 @@
|
||||
GameView *gameView = [[GameView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame];
|
||||
self.view = gameView;
|
||||
|
||||
[TouchPanel instance].displayWidth = self.view.bounds.size.width;
|
||||
[TouchPanel instance].displayHeight = self.view.bounds.size.height;
|
||||
[TouchPanel instance].displayOrientation = [GameViewController getDisplayOrientationForInterfaceOrientation:self.interfaceOrientation];
|
||||
TouchPanel *touchPanel = [TouchPanel getInstance];
|
||||
touchPanel.displayWidth = self.view.bounds.size.width;
|
||||
touchPanel.displayHeight = self.view.bounds.size.height;
|
||||
touchPanel.displayOrientation = [GameViewController getDisplayOrientationForInterfaceOrientation:self.interfaceOrientation];
|
||||
|
||||
[gameView release];
|
||||
}
|
||||
@ -110,19 +111,19 @@
|
||||
// Touches
|
||||
|
||||
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||
[[TouchPanel instance] touchesBegan:touches withEvent:event];
|
||||
[[TouchPanel getInstance] touchesBegan:touches withEvent:event];
|
||||
}
|
||||
|
||||
- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||
[[TouchPanel instance] touchesMoved:touches withEvent:event];
|
||||
[[TouchPanel getInstance] touchesMoved:touches withEvent:event];
|
||||
}
|
||||
|
||||
- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||
[[TouchPanel instance] touchesEnded:touches withEvent:event];
|
||||
[[TouchPanel getInstance] touchesEnded:touches withEvent:event];
|
||||
}
|
||||
|
||||
- (void) touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||
[[TouchPanel instance] touchesCancelled:touches withEvent:event];
|
||||
[[TouchPanel getInstance] touchesCancelled:touches withEvent:event];
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
|
@ -23,8 +23,6 @@
|
||||
|
||||
BOOL beginCalled;
|
||||
|
||||
int drawCalls;
|
||||
|
||||
NSMutableArray *sprites;
|
||||
VertexPositionColorTextureArray *vertexArray;
|
||||
}
|
||||
|
@ -6,10 +6,9 @@
|
||||
// Copyright 2010 Retronator. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SpriteBatch.h"
|
||||
|
||||
#import "Retronator.Xni.Framework.h"
|
||||
#import "Retronator.Xni.Framework.Graphics.h"
|
||||
#import "SpriteBatch.h"
|
||||
|
||||
typedef struct {
|
||||
float x;
|
||||
@ -312,6 +311,7 @@ static VertexPositionColorTextureStruct vertices[4];
|
||||
switch (sortMode) {
|
||||
case SpriteSortModeImmediate:
|
||||
// We've already done all the work.
|
||||
beginCalled = NO;
|
||||
return;
|
||||
case SpriteSortModeTexture:
|
||||
[sprites sortUsingDescriptors:textureSort];
|
||||
|
@ -24,14 +24,17 @@
|
||||
NSMutableDictionary *touchLocations;
|
||||
}
|
||||
|
||||
+ (TouchPanel*) instance;
|
||||
|
||||
@property (nonatomic) int displayWidth;
|
||||
@property (nonatomic) int displayHeight;
|
||||
@property (nonatomic) DisplayOrientation displayOrientation;
|
||||
@property (nonatomic) GestureType enabledGestures;
|
||||
@property (nonatomic, readonly) BOOL isGestureAvailable;
|
||||
|
||||
+ (TouchCollection*) getState;
|
||||
+ (GestureSample*) readGesture;
|
||||
|
||||
+ (TouchPanel*) getInstance;
|
||||
|
||||
- (TouchCollection*) getState;
|
||||
- (GestureSample*) readGesture;
|
||||
|
||||
|
@ -95,20 +95,29 @@ static TouchPanel *instance;
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
+ (void) initialize {
|
||||
instance = [[TouchPanel alloc] init];
|
||||
}
|
||||
|
||||
+ (TouchPanel*) instance {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@synthesize displayWidth;
|
||||
@synthesize displayHeight;
|
||||
@synthesize displayOrientation;
|
||||
@synthesize enabledGestures;
|
||||
|
||||
+ (TouchCollection*) getState {
|
||||
return [instance getState];
|
||||
}
|
||||
|
||||
+ (GestureSample*) readGesture {
|
||||
return [instance readGesture];
|
||||
}
|
||||
|
||||
|
||||
+ (TouchPanel*) getInstance {
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
- (BOOL) isGestureAvailable{
|
||||
return NO;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user