[MV]어떤 인풋을 받았을때 특수한 행동을 취하는 캐릭터 구현에대한 질문

by huguduk posted Jul 12, 2016
?

단축키

Prev이전 문서

Next다음 문서

ESC닫기

크게 작게 위로 아래로 댓글로 가기 인쇄

안녕하세요, 질문이곧 내용입니다만 좀 부연설명을 해드리면..

 

 

어떤 키를 눌렀을때 캐릭터가 어떤 모션을 취하는것을 만들고싶습니다.

 

그 모션은 일반 캐릭터 타일셋에는 없는 모양이구요, 그래서 단순하게 아래와 같이 구현을 해보았습니다.

 

Sprite_Character.prototype.updateCharacterFrame = function() {    
    var pw = this.patternWidth();
    var ph = this.patternHeight();
    var sx = (this.characterBlockX() + this.characterPatternX()) * pw;
    var sy = (this.characterBlockY() + this.characterPatternY()) * ph;
    this.updateHalfBodySprites();    

    if (this._weaponSprite.isPlaying()) {
        this.bitmap = ImageManager.loadCharacter(this._characterName + "Attacking");
        this.setFrame(1, sy, pw, ph);
    }

    else{
        this.bitmap = ImageManager.loadCharacter(this._characterName);
        if (this._bushDepth > 0) {
            var d = this._bushDepth;
            this._upperBody.setFrame(sx, sy, pw, ph - d);
            this._lowerBody.setFrame(sx, sy + ph - d, pw, d);
            this.setFrame(sx, sy, 0, ph);
        } else {
            this.setFrame(sx, sy, pw, ph);
        }
    }
};

 

검게칠한 부분 외에는 기존 함수의 기능과 같구요,

 

단순하게, 어떤 상황일때( 공격버튼을 누르면 웨폰이미지가 실행되는동안 ) 캐릭터가 다른 모션을 취하기위해

 

다른 캐릭터칩을 불러  타일의 특정부분 위치를 모션동안 setFrame을 통해 재생하게 합니다. 

 

 

 

동작이 되긴하는데, 막상 자신이 없는게  화면상에 보이는 캐릭터에게 특수한 움직임을 

 

부여할때 위와같은 방식으로 구현하는것이 맞는지 궁금합니다.

(클래스의 구조적인 측면보다 실제 프로그래밍 로직 측면에서 저런식으로 작동하게 하는것이 맞는지 궁금합니다.)

 

작은조언이라도 감사히 받겠습니다.


 


Articles

13 14 15 16 17 18 19 20 21 22