나는 이길 게임을 만들고 지금 당장 내 캐릭터를 걷고 뛰어 내리고있다. 지금까지 3 번의 공격 애니메이션이 있었는데 막 작동합니다. 이것은 내가 달성하려고하는 것입니다. 플레이어가 공격 버튼을 누른 다음 캐릭터가 공격하고 플레이어가 공격 버튼을 계속 누르고 있으면 공격/펀칭 시퀀스가 계속되거나 다른 공격 키가 눌러 진 경우입니다. 스위치 공격/발 차기 애니메이션 (참고 : 플레이어가 키를 누르고 있으면 키를 눌러야합니다.)내 캐릭터 싸움 만들기
또한 현재 공격 애니메이션이 현재 공격 애니메이션의 다음 프레임으로 이동하는 대신 현재 공격 애니메이션이 완전히 끝나면 어떻게하면 다음 공격 애니메이션으로 갈 수 있습니까? 캐릭터가 공격을하고 공격 키를 누르면 캐릭터는 현재의 공격 애니메이션을 끝내고 다음 공격 애니메이션 프레임으로 이동합니다. 그렇지 않으면 중지됩니다. 배열을 만들거나 클래스를 확장해야하는 이유는 무엇입니까? 나는 이런 식으로 내가 발견 사본을 게임을 만들려고하지만, AS2에
https://www.dropbox.com/s/zhf68zmi0ktmeqq/DD%20%282%29.zip
이 내가 지금까지 한 일 자사의
당신이 시도조차 시도하지 않은 것 같습니다package
{
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
import flash.utils.*;
import com.greensock.TweenLite;
import com.greensock.easing.*;
import com.greensock.plugins.*;
public class Player extends MovieClip
{
TweenPlugin.activate([BlurFilterPlugin]);
//Player run speed setting;
var RunSpeed:Number = 8;
//Player key presses
var RightKeyPress:Boolean = false;
var LeftKeyPress:Boolean = false;
var UpKeyPress:Boolean = false;
//Jump variables
var Gravity:Number = 1.5;
var JumpPower:Number = 0;
var CanJump:Boolean = false;
var Jumped:Boolean = false;
//Dash variable
var Pressed:Boolean = false;
var LastKeyPressed:Number = -1;
var DashAmount:Number = 250;
var DoubleTapDelay:Number = 260;//-- delay in milliseconds
var Dashing:Boolean = false;
var RightDash:Boolean = false;
var LeftDash:Boolean = false;
public function Player()
{
stage.addEventListener(KeyboardEvent.KEY_DOWN,KeyDown);
stage.addEventListener(KeyboardEvent.KEY_DOWN,KeyPressed);
addEventListener(Event.ENTER_FRAME,Update);
}
function KeyDown(event:KeyboardEvent)
{
stage.removeEventListener(KeyboardEvent.KEY_DOWN, SecondDash);
//If key is down cannot dash
RightDash = false;
LeftDash = false;
//When Key is Down
if (event.keyCode == 39)
{
RightKeyPress = true;
}
if (event.keyCode == 37)
{
LeftKeyPress = true;
}
if (event.keyCode == 38)
{
UpKeyPress = true;
}
}
function KeyPressed(event:KeyboardEvent):void
{
stage.removeEventListener(KeyboardEvent.KEY_DOWN, KeyPressed);
stage.addEventListener(KeyboardEvent.KEY_UP, KeyUp);
//If on floor
if (CanJump)
{
//If right key is down
if (event.keyCode == 39)
{
if (event.keyCode == 39 && Pressed)
{
//If right key press matches with recent right key press, dash right
Dashing = true;
RightDash = true;
}
Pressed = true;
setTimeout(function(){Pressed = false}, DoubleTapDelay);
}
if (event.keyCode == 37)
{
if (event.keyCode == 37 && Pressed)
{
//If left key press matches with recent left key press, dash left
Dashing = true;
LeftDash = true;
}
Pressed = true;
setTimeout(function(){Pressed = false}, DoubleTapDelay);
}
}
}
function Update(event:Event)
{
//Adding gravity to the game world
JumpPower += Gravity;
//if player is more than 300 on the y-axis
if (this.y > 300)
{
//Player stays on the ground and can jump
JumpPower = 0;
CanJump = true;
}
//If already jumped and on floor
if (Jumped == true && CanJump)
{
//Cannot jump again
CanJump = false;
//If on floor and right key is pressed run right
if ((RightKeyPress))
{
gotoAndStop('Run');
scaleX = 1;
}
else if ((LeftKeyPress))
{
//Otherwise if on floor and left key is pressed run left
gotoAndStop('Run');
scaleX = -1;
}
//If no key is pressed stay idle
if ((!RightKeyPress && !LeftKeyPress))
{
gotoAndStop('Idle');
}
}
//If on floor and can jump
if (CanJump)
{
//If right key is pressed run right
if ((RightKeyPress))
{
x += RunSpeed;
gotoAndStop('Run');
scaleX = 1;
}
else if ((LeftKeyPress))
{
//otherwise if left key is pressed run left
x -= RunSpeed;
gotoAndStop('Run');
scaleX = -1;
}
if ((UpKeyPress))
{
//If up key is pressed then jump
JumpPower = -15;
CanJump = false;
gotoAndStop('Jump');
Jumped = true;
}
//If no key is pressed stay idle
if ((!RightKeyPress && !LeftKeyPress && CanJump))
{
gotoAndStop('Idle');
}
}
else if (CanJump == false)
{
//Otherwise if in air and right key is pressed move right
if ((RightKeyPress))
{
x += RunSpeed;
scaleX = 1;
}
else if ((LeftKeyPress))
{
//Otherwise if left key is pressed then move left
x -= RunSpeed;
scaleX = -1;
}
}
//If Dashing is true
if (Dashing == true)
{
//Dash right
if (RightDash == true)
{
stage.addEventListener(KeyboardEvent.KEY_DOWN, SecondDash);
stage.removeEventListener(KeyboardEvent.KEY_DOWN, KeyPressed);
TweenLite.to(this,0,{blurFilter:{blurX:1000}});
TweenLite.to(this,0.2,{blurFilter:{blurX:0},x:x + DashAmount,ease:Expo.easeOut});
Dashing = false;
}
else if (LeftDash == true)
{
//Otherwise dash left
stage.addEventListener(KeyboardEvent.KEY_DOWN, SecondDash);
stage.removeEventListener(KeyboardEvent.KEY_DOWN, KeyPressed);
TweenLite.to(this,0,{blurFilter:{blurX:1000}});
TweenLite.to(this,0.2,{blurFilter:{blurX:0},x:x - DashAmount,ease:Expo.easeOut});
Dashing = false;
}
}
else if (Dashing == false)
{
stage.removeEventListener(KeyboardEvent.KEY_DOWN, SecondDash);
}
this.y += JumpPower;
}
function SecondDash(event:KeyboardEvent)
{
stage.removeEventListener(KeyboardEvent.KEY_DOWN, SecondDash);
if (event.keyCode == 38)
{
TweenLite.to(this,0,{blurFilter:{blurX:0}});
TweenLite.to(this,0,{blurFilter:{blurY:1000}});
TweenLite.to(this,0.5,{blurFilter:{blurY:0},y:y - DashAmount,ease:Expo.easeOut});
}
}
function KeyUp(event:KeyboardEvent)
{
stage.addEventListener(KeyboardEvent.KEY_DOWN, KeyPressed);
RightDash = false;
LeftDash = false;
if (event.keyCode == 39)
{
RightKeyPress = false;
}
if (event.keyCode == 37)
{
LeftKeyPress = false;
}
if (event.keyCode == 38)
{
UpKeyPress = false;
Jumped = false;
}
}
}
}
도움을 주셔서 감사합니다하지만 난 그냥 더 튜토리얼을하거나 그냥 포기 것, 그것이 작동 할 수없는 것, 내가/프로그래밍 코딩 추측하는 것은 모든 사람 덕분위한 것이 아닙니다 어쨌든 – user2350724
검색 "마이클 제임스 Avoider 게임 자습서 "구글. 나는 완벽한 게임을 만드는 방법을 가르쳐주는 가장 좋은 게임 중 하나라고 생각합니다. 그것은 아마도 당신이 그것을 다시하고 자신의 게임을 비슷하게 만들면 잘 배우는 데 일주일 정도 걸릴 것입니다. 그러나 일주일 정도 지나면 약속이 훨씬 편안해질 것입니다. – spaderdabomb