1

无论如何,当我的游戏在 iPhone 上运行时,我可以通过捏缩放来为我的游戏工作吗?

我使用 Stencylworks 为一个班级项目制作了游戏。该游戏在 iPad 上运行完美,也可以在 iPhone 上运行,只是场景被放大了,这使得玩起来非常困难。

有没有办法实现缩小的捏合手势?也许可以在 Xcode 中使用视图控制器或在某处添加代码来完成?我是 Xcode 的新手,所以我完全不知道如何让它工作!

不确定这是否会有所帮助,但这里有一些项目的屏幕截图。

https://sites.google.com/site/boomblocksgld/pinch-to-zoom

>

#import <Box2D/Box2D.h>
#import <Foundation/Foundation.h>
#import <AudioToolbox/AudioServices.h> 
#import "SceneScript.h"

#import "Script.h"

#import "Actor.h"
#import "ActorType.h"
#import "Assets.h"
#import "Behavior.h"
#import "Game.h"
#import "GameModel.h"
#import "GroupDef.h"
#import "FadeInTransition.h"
#import "FadeOutTransition.h"
#import "Region.h"
#import "Runnable.h"
#import "Scene.h"
#import "SHThumbstick.h"
#import "Sparrow.h"
#import "Transition.h"
#import <Foundation/Foundation.h>
#import <CoreGraphics/CoreGraphics.h>
#import <UIKit/UIKitDefines.h>

@protocol UIGestureRecognizerDelegate;
@class UIView, UIEvent, UITouch;


@interface Design_353_353_PinchZoom : SceneScript 
{
  @public
      NSString* tempHolder;

}
@end

@implementation Design_353_353_PinchZoom


-(void)load
{

}

-(void)update
{  
}
// Gesture Reconizer Methods
-(void)checkpinch {    

UIPinchGestureRecognizer *pinch = [[UIPinchGestureRecognizer     >alloc]initWithTarget:self action:@selector(checkpinch)];
[pinch setDelegate:self];
[pinch setDelaysTouchesBegan:YES];
[self.view addGestureRecognizer:pinch];
[pinch release];
}


-(void)render:(SPRenderSupport*)g x:(int)x y:(int)y
{
[super render:g x:x y:y];

}



-(void)forwardMessage:(NSString*)msg
{

}

@end
4

1 回答 1

1

如果您使用的是 iOS 3.2 或更高版本,请在 Viewdidload 中添加以下代码。并在 .h 文件中添加 UIGestureRecognizerDelegate

//Gesture reconizer
UIPinchGestureRecognizer *pinch = [[UIPinchGestureRecognizer alloc]initWithTarget:self action:@selector(checkpinch)];
[pinch setDelegate:self];
[pinch setDelaysTouchesBegan:YES];
[self.view addGestureRecognizer:pinch];
[pinch release];

UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(checktap)];
[singleTap setDelegate:self];
singleTap.numberOfTapsRequired = 1;
singleTap.numberOfTouchesRequired =2;
[self.view addGestureRecognizer:singleTap];
[singleTap release];


UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(checktap)];
[doubleTap setDelegate:self];
doubleTap.numberOfTapsRequired = 2;
doubleTap.numberOfTouchesRequired =1;
[self.view addGestureRecognizer:doubleTap];
[doubleTap release];


// Gesture Reconizer Methods
-(void)checkpinch {    

    //write here code for your requirements
}

-(void)checktap {

    //write here code for your requirements
}

我希望这会帮助你......冷静

于 2012-04-16T04:04:51.100 回答