가로 이동을 통해 객체의 movemnt를 작성하는 코드가 있습니다. 초기화 한 Statment에서cocos2d에서 화면 제목을 지정하여 객체를 이동하는 방법
#define kAccelerationSpeed 10
#define kAccelerometerFrequency 200
-(void) accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration
{
CGPoint pt = thePlayer.position ;
CGFloat accel = acceleration.x * kAccelerationSpeed;
pt = [[CCDirector sharedDirector] convertToGL:pt];
pt = ccp (pt.x+accel>0 , yLocationOfPlayer+accel<768);
}
-(id) init
{
// always call "super" init
// Apple recommends to re-assign "self" with the "super" return value
if((self=[super init])) {
[[UIAccelerometer sharedAccelerometer] setUpdateInterval:(1.0/kAccelerometerFrequency)];
[[UIAccelerometer sharedAccelerometer] setDelegate:self];
}
무슨 잘못 위의 코드와, 내가 화면을 기울일 때 작동하지 않습니다, 그것은 "theplayer"object.please 도움에 대한 movemnt을하지 않습니다 나를 이렇게해라.
미리 감사드립니다.
개체를 이동시키는 것은 무엇입니까? 나는 그 어떤 코드도 보지 못합니까? 또한 +/- 최대 가속도에 대한 10 픽셀은 그다지 확신 할 수 없습니다 ... –
@ H2CO3 빠른 답장을 보내 주셔서 감사합니다. pt = ccp (pt.x + accel> 0, yLocationOfPlayer + accel <768); thepalyer 객체를 움직일만큼 충분합니까? cocos2d, postion.x.the accelartion 속도에서 newbe 오전 0, 그것은 왼쪽으로 이동합니다,이 logic.if 어떤 가끔, 제발 도와주세요 – stackiphone
@ H2CO3 도이 코드를 추가하지만 그것은 ID 이동 woking 아니에요 = [CCMoveTo actionWithDuration : 1.0f position : CGPointMake (pt.x + accel> 0, yLocationOfPlayer + accel <768)]; [thePlayer runAction : move]; – stackiphone