2
我有一列精靈,因爲一個精靈離開屏幕,我想讓同一個精靈包圍對面,這樣兩個精靈同時顯示,一個屏幕移動另一個移動到屏幕上,其他發送的精靈不再可見。我被告知要製作一個ccnode,在這裏做所有事情都是我的代碼,但沒有一個可行,所以我認爲我需要再次從頭開始。 這裏是我的最後一個問題的鏈接以獲得更多信息:When sliding sprite, if sprite disappears off the side, it will wrap around to the opposite side?創建一個循環與多個精靈?
這裏是我的代碼反正:
for (int i =0; i<16; ++i) {
MyNode *currentSprite = [c1array objectAtIndex:i];
if (currentSprite.contentSize.height>=320 || currentSprite.position.y-currentSprite.contentSize.height/2<=0){
MyNode *Bsprite = currentSprite;
MyNode *Tsprite = currentSprite;
Bsprite.scale = 1.0;
Tsprite.scale = 1.0;
if(currentSprite.position.y >=253){
Bsprite.position = ccp(currentSprite.position.x,-35);
[self addChild:Bsprite];
Bsprite.visible = TRUE;
}
if (currentSprite.position.y <=0) {
Tsprite.position = ccp(currentSprite.position.x,324);
[self addChild:Tsprite];
Tsprite.visible = TRUE;
}
MyNode *isChanging;
if ((Tsprite.visible == TRUE && currentSprite.visible == TRUE) || (Bsprite.visible == TRUE && currentSprite.visible == TRUE)) {
isChanging = TRUE;
}
if (isChanging == FALSE) {
[self removeChild:Tsprite cleanup:YES];
[self removeChild:Bsprite cleanup:YES];
}
}
}
我想再次啓動代碼,因爲它是一個完整的混亂,需要一個更簡單的方法來允許這種情況發生,因爲tsprite/bsprite進入他們需要觸摸啓用的頁面,當他們離開時,精靈失敗必須再次回來,所以我希望有人能從一開始就幫助我,因爲我的代碼在各處都遇到了太多問題。 – Dangermouse 2011-03-30 18:18:59