這是關於JAVA中的動畫。在所有圖片上使用相同的尺寸時,我獲得了成功。但是,如果我將所有圖片尺寸保持在相同的尺寸(寬度和高度),我會得到一些錯誤,當玩家拳打。在玩家的手碰到敵人身體之前,敵人死了JAVA:2D遊戲冒險。碰撞檢測問題
但是其他與我的情況在空閒,跑步和衝擊有不同 維度。面向左邊的衝孔動畫變得非常奇怪。 他的手應該撞到左邊,但他的身體向右移動。這 是因爲我畫的x & y是一樣的。
我該如何解決?需要說明:d
我使用PNG堂妹支持透明
我認爲這是可以用2選項修復時一定條件下發生
這是關於JAVA中的動畫。在所有圖片上使用相同的尺寸時,我獲得了成功。但是,如果我將所有圖片尺寸保持在相同的尺寸(寬度和高度),我會得到一些錯誤,當玩家拳打。在玩家的手碰到敵人身體之前,敵人死了JAVA:2D遊戲冒險。碰撞檢測問題
但是其他與我的情況在空閒,跑步和衝擊有不同 維度。面向左邊的衝孔動畫變得非常奇怪。 他的手應該撞到左邊,但他的身體向右移動。這 是因爲我畫的x & y是一樣的。
我該如何解決?需要說明:d
我使用PNG堂妹支持透明
我認爲這是可以用2選項修復時一定條件下發生
1.修復我的碰撞檢測 2.修正描繪位置我的形象試圖描繪你的問題,希望這會有所幫助。 我直接從我的頭typeing,所以有代碼
威力錯誤固定coalision decection 我會嘗試這個
Image fist
Image enemy
//in paint
g2D.drawImage(fist,x,y,this);
g2D.drawImage(enemy,x1,y1,this);
Rectangle2D myFist = new Rectangle2D.Double(x,y,fist.getWidth(this),fist.getHeight(this));
Rectangle2D myEnemy = new Rectangle2D.Double(x1,y1,enemy.getWidth(this),enemy.getHeight(this));
if (myEnemy.contains(myFist){
//action u want to happend
}
我覺得這樣的事情應該可以解決coalision問題 我認爲這是馬里奧在賽格的一場比賽
修復描繪位置
//arm image can be the same image if u want
Image leftArm;
Image rightArm;
image headLegsAndTorsoLeft;
image headLegsAndTorsoRight;
//where am i looking in game if true i look to the leftside of user thats playing
boolean turnedLeft
//in paint
if(turnedLeft){
//this lets it look like he is turned to the left with his right arm in the visible behind his left.
//draw right arm
g2D.drawImage(rightArm,x,y,this);
//draw body moved a bit in x coor
g2D.drawImage(headLegsAndTorsoLeft,x-3,y,this);
// draw left arm a bit more in x coor
g2D.drawImage(leftArm,x-6,y,this);
}else{
//this lets it look like he is turned to the right with his left arm in the visible behind his right.
// draw left arm
g2D.drawImage(leftArm,x,y,this);
//draw body moved a bit in x coor
g2D.drawImage(headLegsAndTorsoRight,x-3,y,this);
//draw right arm a bit more in x coor
g2D.drawImage(rightArm,x-6,y,this);
}
相同的順序武器動畫,ultimatly我會用不同的方法動畫的軀幹,leftarm,rightarm 類似的keyPressed LEFTARROW軀幹不走動畫左,打左左臂鍵移動手臂,打右臂鍵移動右臂,那3讓我們說左手臂,現在你需要另一個3當你的字符移到右邊。
這就是我將如何嘗試做事情。
嗯... thx ... 我想我會選擇解決我的煤礦偵察...... – Kenjiro 2011-06-12 03:20:47