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