RMMV

스프라이트 객체에서 이벤트 객체를 참조하는 식별자 위치 관련.

by A구몽 posted Sep 16, 2018
?

단축키

Prev이전 문서

Next다음 문서

ESC닫기

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

자바스크립트에서 객체가 담긴 주소를 비우고 참조중인 식별자들을 모두 삭제하고싶어요. 

가능한가요?

비슷한 거라도 괜찮습니다.


목적은  생성자 Game_Event로 부터 생성된 객체를 참조하고 있는 식별자를 모두 제거하여 완전한 이벤트 객체의 소멸 입니다.


$gameMap._events[n] 을 undefiend로 변경하였으나 이벤트 객체가 사라지지 않고 쌓여 렉이 발생하는 것을 보고

이벤트 객체를 모두 비워버리고 $gameMap._events[n]에 undefined를 대입하니 Sprite 쪽에서 버그가 생기더라고요.(객체의 프로퍼티를 모두 비워버린 것이 원인. 이미 활용이 끝난 객체가 아직도 참조되고있는 것이 문제.)

아마 이벤트를 매 프레임마다 그리기 위해 이벤트 객체를 참조하는 것 같은데 그 식별자를 도저히 못찾겠습니다.

읽어오는 부분이 아마 $gameMap.events 는 아닌 것 같습니다.


Sprite_Character.prototype.setCharacterBitmap = function() {
this.bitmap = ImageManager.loadCharacter(this._characterName);
this._isBigCharacter = ImageManager.isBigCharacter(this._characterName); //이벤트 객체의 _characterName
}; //읽어오는 것 예상


Spriteset_Map.prototype.createCharacters = function() {
this._characterSprites = [];
$gameMap.events().forEach(function(event) {
this._characterSprites.push(new Sprite_Character(event)); //이 부분에서 this._characterSprites 가
}, this); //이벤트 객체를 읽거나 참조하는 것 예상
$gameMap.vehicles().forEach(function(vehicle) {
this._characterSprites.push(new Sprite_Character(vehicle));
}, this);
$gamePlayer.followers().reverseEach(function(follower) {
this._characterSprites.push(new Sprite_Character(follower));
}, this);
this._characterSprites.push(new Sprite_Character($gamePlayer));
for (var i = 0; i < this._characterSprites.length; i++) {
this._tilemap.addChild(this._characterSprites[i]);
}
};

 

Scene_Map.prototype.createSpriteset = function() {
this._spriteset = new Spriteset_Map(); //결국 참조하고 있는 식별자를 알아내지 못했습니다.
this.addChild(this._spriteset); //Scene_Map은 SceneManager.goto 를 통해서만 객체를 생성하는 것
}; //같은데 다시 프로토타입을 따라 올라가고 있는 저를 발견하였습니다...

 

 객체 삭제 아니면 저 망할 이벤트 객체(Game_Event로 생성된 객체)를 어떻게든 없애버리고 싶습니다.


Sprite_Character  생성자로 생성된 객체를 참조하는 식별자가 무엇인지 알려주셔도. 좋습니다.


질문이 여러개로 나뉘어졌는데 답변이 확정되면 수정하겠습니다.

■ 질문전 필독!
  • 질문할 내용이 이 게시판이나 강좌에 이미 있는지 확인합니다.
  • 하나의 게시물에는 하나의 질문만 합니다.
  • 제목은 질문의 핵심 내용으로 작성합니다.
  • 질문 내용은 답변자가 쉽게 이해할 수 있도록 최대한 상세하게 작성합니다.
  • 스크립트의 전문이 필요할 경우 txt 파일 등으로 첨부해 주시기 바랍니다.
  • 답변받은 게시물은 삭제하지 않습니다.
  • 답변이 완료된 경우 해당 답변해주신 분들께 감사의 댓글을 달아줍니다.
    • 처음 오신 분들은 공지 게시물을 반드시 읽어주세요!

※ 미준수시 사전경고 없이 게시물을 삭제합니다.

Who's A구몽

profile

닉네임 변경

6º   ->  A구몽