我目前正在研究AS3中的一個漂亮的小2D遊戲引擎。您甚至可以通過XML爲不同的動畫加載不同的Flash影片剪輯。其中一項功能還允許您在執行特定操作時翻轉動畫。這樣,你可以有左右兩個動畫(如往常一樣)。我有矩陣轉換正常工作;然而,我認爲我的邏輯來回翻轉事物是不正確的。結果是錯誤的動畫會在錯誤的時間播放。我決定根據移動物體的速度而不是按鍵來播放動畫,因爲我涉及到物理元素。錯誤的矩陣翻轉(鏡像反射)MovieClip
這裏是遊戲的鏈接在其當前狀態:http://parrisstudios.com/Game_Design/gameEngineDemo/
問題主要在於動畫在不正確的時間玩,還是不要當他們應該扮演。
這裏是我翻轉的代碼(讓我知道你們的想法): ps:方向變量是角色面對的最後方向(在這種情況下是左或右,稍後會在代碼中進行描述)
private function drawJumpMode():void {
var change:Boolean = false;
//decide whether to swap graphics or continue playing
if (Math.abs(particleGroup.particles[0].velocity.y) < epsilon && Math.abs(particleGroup.particles[0].velocity.x) < epsilon && direction == "right") {
if (lastClipAction != "stillRight"){
lastClipAction = "stillRight";
change = true;
}
}
else if (Math.abs(particleGroup.particles[0].velocity.y) < epsilon && Math.abs(particleGroup.particles[0].velocity.x) < epsilon && direction == "left") {
if (lastClipAction != "stillLeft"){
lastClipAction = "stillLeft";
change = true;
}
}
else if (particleGroup.particles[0].velocity.y > 0 && Math.abs(particleGroup.particles[0].velocity.x) < epsilon) {
if (lastClipAction != "down"){
lastClipAction = "down";
change = true;
}
}
else if (particleGroup.particles[0].velocity.y < 0 && Math.abs(particleGroup.particles[0].velocity.x) < epsilon) {
if (lastClipAction != "up"){
lastClipAction = "up";
change = true;
}
}
else if (particleGroup.particles[0].velocity.x > 0) {
if (lastClipAction != "right") {
lastClipAction = "right";
direction = "right";
change = true;
}
}
else if (particleGroup.particles[0].velocity.x < 0) {
if (lastClipAction != "left"){
lastClipAction = "left";
direction = "left";
change = true;
}
}
//If the movie clip has changed, swap the old one back into the all clips library and get the new one.
if (change) {
//set flip to false whenever there is a change in movie clip
flipped = false;
//if the movie clip was flipped before, this should flip it
//back to normal
flip();
//remove movie clip from the scene
game.removeChild(playingMovieClip);
//check it back into the movie clip library
allClips.addChild(playingMovieClip);
//add the movie clip into the scene
playingMovieClip = MovieClip(allClips.getChildByName(actionToClip[lastClipAction + "Name"]));
game.addChild(playingMovieClip);
}
//Flip if needed
flip();
//set it to true so that it won't be constantly flipped.
flipped = true;
//set movie clip to be center over the main particle
playingMovieClip.x = particleGroup.particles[0].center.x;
playingMovieClip.y = particleGroup.particles[0].center.y;
}
private function flip():void {
//If a transformation is required, then do so
if (actionToClip[lastClipAction + "H"]=="1" && !flipped){
flipHorizontal(playingMovieClip);
}
if (actionToClip[lastClipAction + "V"]=="1" && !flipped){
flipVertical(playingMovieClip);
}
}
什麼問題?你期望看到什麼,而你看到了什麼?儘量做到儘可能具體。 – Amber
是的,我想這是不清楚。我除了看到所有動畫的玩法完全如我所料。這裏是一個鏈接:http://parrisstudios.com/Game_Design/gameEngineDemo/ 本質上有時圖片翻轉回來,當他們不應該或某些動畫時,他們應該觸發。 – Parris