我是Cocos2D的新手,有誰能告訴我如何做葉子從頂部落下並落在iPad底部,當用戶傾斜iPad或觸摸樹葉時,葉子應該做出相應的迴應。應該類似於愛麗絲仙境lite應用頁碼13動畫。 我張貼我的代碼,但它不表現我想要的。每當我接近精靈時,所有的精靈都會以令人難以置信的力量移動......他們真的會走出我所接觸的地方。當然,我不是唯一一個執行過此操作的人嗎?任何人都能帶領我走向正確的方向嗎?樹葉下降動畫和手指拖動
static float hw = 639.0/2.0,hh = 479.0/2.0; (cpvct(pos.y/size.height,pos.x/size.width),2.0f),cpv(1.0f,1.0),cpVect(pos.y/size.height,pos.x/size.width),2.0f)1.02, F)); V = CPV(V.X * HW,V.Y * 11H); // printf的( 「%S \ n」 個,cpvstr(V)); return v; }
限定GRABABLE_MASK_BIT(1 < < 31)
(無效)ccTouchesBegan:(NSSet中*)觸摸withEvent:方法(的UIEvent *)事件{ UITouch *的myTouch = [觸摸anyObject]; CGPoint位置= [的myTouch locationInView:的myTouch視圖]]; location = [[CCDirector sharedDirector] convertToGL:location];
cpVect point = mouseToSpace([myTouch locationInView:[myTouch view]],[myTouch view] .bounds.size); mousePoint = point;
cpShape * shape = cpSpacePointQueryFirst(space,point,GRABABLE_MASK_BIT,0);
if(shape){cpBody * body = shape-> body; mouseJoint = cpPivotJointNew2(mouseBody,身體,cpvzero,cpBodyWorld2Local(體,點)); mouseJoint-> maxForce = 50000.0f; mouseJoint-> biasCoef = 0.15f; cpSpaceAddConstraint(space,mouseJoint); } }
(無效)ccTouchesMoved:(NSSet中*)觸摸withEvent:方法(的UIEvent *)事件{ UITouch *的myTouch = [觸摸anyObject]; CGPoint位置= [的myTouch locationInView:的myTouch視圖]]; location = [[CCDirector sharedDirector] convertToGL:location];
mousePoint = mouseToSpace([myTouch locationInView:[myTouch view]],[myTouch view] .bounds。尺寸); }
(無效)ccTouchesEnded:(NSSet中*)觸摸withEvent:方法(的UIEvent *)事件{ [自touchesCancelled:觸摸withEvent:方法事件]; }
(無效)touchesCancelled:(NSSet中*)觸摸withEvent:方法(的UIEvent *)事件{ cpSpaceRemoveConstraint(空間,mouseJoint); cpConstraintFree(mouseJoint); mouseJoint = nil; }
任何人請指導我或張貼代碼,我急需它。
等待您的寶貴建議和任何代碼。
在此先感謝。
溼婆。
投票結束,質疑廣泛回答。 – 2010-11-12 12:56:47
任何時候當我讀到「我急需它」時,我覺得有必要評論「美元有多緊急?」 – Kheldar 2011-08-31 22:17:58