我一直在谷歌搜索和搜索堆棧溢出,但有沒有什麼辦法可以找出哪個像素是什麼點?喜歡,是否有一些應用程序可以確定您的指向說,(321,199)?CoCos2d像素和定位
雖然我在這裏,在CoCos2d,我使用iPhone 5.0模擬器,所以我假設它有視網膜顯示。但是,當我告訴CoCos2d將一個精靈放在(516,724)時,我不得不將它縮小到320x480的測量值。我認爲視網膜是640x960。
我一直在谷歌搜索和搜索堆棧溢出,但有沒有什麼辦法可以找出哪個像素是什麼點?喜歡,是否有一些應用程序可以確定您的指向說,(321,199)?CoCos2d像素和定位
雖然我在這裏,在CoCos2d,我使用iPhone 5.0模擬器,所以我假設它有視網膜顯示。但是,當我告訴CoCos2d將一個精靈放在(516,724)時,我不得不將它縮小到320x480的測量值。我認爲視網膜是640x960。
是的,我剛剛想到這確實做到了這
HelloWorld.m
//
// HelloWorldLayer.m
// FindCocosCoord
//
#import "HelloWorldLayer.h"
CCLabelTTF *touchLabelX;
CCLabelTTF *touchLabelY;
CCSprite *touchSprite;
@implementation HelloWorldLayer
+(CCScene *) scene
{
// 'scene' is an autorelease object.
CCScene *scene = [CCScene node];
// 'layer' is an autorelease object.
HelloWorldLayer *layer = [HelloWorldLayer node];
// add layer as a child to scene
[scene addChild: layer];
// return the scene
return scene;
}
-(id) init
{
if((self=[super init])) {
self.isTouchEnabled = YES;
touchLabelX = [CCLabelTTF labelWithString:@"X = " fontName:@"Marker Felt" fontSize:20];
touchLabelX.position = ccp(100,50);
[self addChild:touchLabelX];
touchLabelY = [CCLabelTTF labelWithString:@"Y = " fontName:@"Marker Felt" fontSize:20];
touchLabelY.position = ccp(170,50);
[self addChild:touchLabelY];
touchSprite = [CCSprite spriteWithFile:@"Icon-Small.png"];
touchSprite.position = ccp(0,0);
[self addChild:touchSprite];
}
return self;
}
-(void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch* myTouch = [touches anyObject];
CGPoint location = [myTouch locationInView: [myTouch view]];
location = [[CCDirector sharedDirector]convertToUI:location];
touchSprite.position = location;
touchX = touchSprite.position.x;
touchY = touchSprite.position.y;
NSLog(@"Location X = %i", (int)touchX);
NSLog(@"Location Y = %i", (int)touchY);
NSString *touchXstring = [NSString stringWithFormat:@"X = %i", (int)touchX];
NSString *touchYstring = [NSString stringWithFormat:@"Y = %i", (int)touchY];
[touchLabelX setString:touchXstring];
[touchLabelY setString:touchYstring];
}
- (void) dealloc
{
[super dealloc];
}
@end
HelloWorld.h
#import "cocos2d.h"
@interface HelloWorldLayer : CCLayer
{
int touchX,touchY;
}
+(CCScene *) scene;
@end
就像UIKit的一個示例應用程序,茯苓,很容易讓你通過與「積分」合作來處理兩項決議。
在非視網膜顯示中的一個點是一個像素,但在視網膜顯示器上,它是兩個像素寬和兩個像素高。
因此,即使在視網膜設備上工作,您也可以使用320x480點的網格。
哇,謝謝你。但是我的另一個問題是,視網膜屏幕上的點有什麼問題?座標是否仍然相同,它們的顯示方式有何不同? – 2012-02-15 03:06:24
爲什麼你會接受一個答案,當我的問題沒有回答你的問題?這就是爲什麼我們不能有好的東西... – EmilioPelaez 2012-02-15 06:23:55
視網膜顯示是相同的豆莢。 (320x480)作爲上一代iphone – mattblessed 2012-02-15 18:57:22