the object function not exist after load game

hi everyone, i need help at this case

i use 'use strict' & create new class like this

0001.jpg


0002.jpg



OK ~ it can running in the game
0003.jpg




but , after save game -> back to title scene -> load game
i had error 「undefined is not a function」

than i check console log


0004.jpg



the call function was not exist

Can someone help me or know why?
Can we see a picture of the actual error in the console? That will help a ton. I assume it has to do with you saving that class with the save file, maybe a small snippet of how you're achieving this will help as well.
The first thing to check is to make sure that the objects are restored as instances of SLGCharacter_Base after the load game.
thx guys !
load game will run this
0006.jpg



when call getHeroID() , it will error

that is error console, i track the obj (SLGLeader)
0007.jpg

0008.jpg



# SLGCharacter_Base extends Game_Character
# SLGLeader extends SLGCharacter_Base


0009.jpg


the_battlersLayer will add child SLGLeader
that is SLGCharacter_Base class

Code:
class SLGCharacter_Base extends Game_Character {
    constructor (layer, objData, heroType){
        super(layer, objData, heroType);
    }
    initialize (layer, objData, heroType){
        Game_Character.prototype.initialize.call(this, layer, objData , heroType);   
        // 物件基本資料
        this._cell = this._cell || {};
        this._cell.x = objData.x;
        this._cell.y = objData.y;                       
        this._camp = null;
        this._objData = this.getObjData(objData.id);

        this._characterName = this._objData.CHAR_NAME; // 圖片名稱
        this._characterIndex = this._objData.CHAR_INDEX; // 圖片id
        this._arang = this._objData.ARANG; // 攻擊範圍
       
        this._ID = this._objData.ID; // 對應id
        this._at = this._objData.AT; // 對應攻擊力 
        this._df = this._objData.DF; // 對應防禦力
        this._md = this._objData.MD; // 對應魔法防禦
        this._mv = this._objData.MV; // 對應移動力
       
        this._exp = this._objData.EXP; // 擊倒可獲得經驗值   
        this._name = this._objData.CHARA || '測試' ; // 對應的角色名稱
        this._type = this._objData.TYPE; // 對應兵種   
        this._heroType = heroType; // 1:指揮官 2: 傭兵
        this._hp = 10;       
    }
    getHeroHp (){
        return this._hp;
    }
    setHeroType (type){
        this._heroType = type;
    }
    getHeroType (){
        return this._heroType;
    }

    getObjData (id){} // 複寫專用   

    screenX () {
       var tw = $gameMap.tileWidth();
       return Math.round(this.scrolledX() * tw + tw / 2);
    };
    screenY () {
       var th = $gameMap.tileHeight();
       return Math.round(this.scrolledY() * th + th -
                         this.shiftY() - this.jumpHeight());
    };
    createrSprite(layer, objData ){
        // this._sprite = new SLGLeader_Sprite(this);
        this.setPosition(this._cell.x , this._cell.y);
        // this._bushDepth = 12; // 草叢
        // layer.addChild(this._sprite);
    }
    setThrough (through){
        this._through = through;
    }   
    setCamp (camp){
        this._camp = camp;
    }
    getCampp (){
        return this._camp;
    }
    getHeroID (){
        return this._ID;
    }

}
The error is happening because you are trying to run the forEach() against an object when it's a native array function only. Somewhere in your code in the ManagerTool.js is where the error occurs. I don't see anything in the code you showed me that is using a forEach() function.

Edit, sorry I never noticed the screenshot (must have loaded after) of your code which uses the forEach(). Are you sure it's returning an array?

Edit Again: I took a closer look. the GetHeroID() is returning not a function, it's because it's not defined in your class. I see everything else but that function. Again sorry for the constant edits, I must have skipped the entire first post and I'm scanning through what I see now.
hi , i change the code ... class to prototype , then , it can load game and not had error
like this
0011.jpg



but .... after change , this time , it cant save game, when i pressed save game , it will ERRO and cant save file
this is conesole

0010.jpg



i dont know how to do orz...
Okay, so your original ES6 class, you are missing the initialize in the constructor function.
PHP:
class SLGCharacter_Base extends Game_Character {
    constructor (layer, objData, heroType){
        super(layer, objData, heroType);
        // This was missing
        this.initialize()
    }
Which is probably why you had an error, the class properties were not being initialized. Now that you converted to an ES5 constructor function, you initialized your properties which is why it worked for loading but now you have a new error when saving... Yies! The beauty of programming 🙂.

This error is directly linked to the savefile method in data manager, it's a hard one to debug to but not impossible. Somewhere in your script you are attempting to save an object's property, of an object that does not exist.

I don't know where unless I have you script with me but I'm sure you will find it. I'd recommend taking a look at the contents being saved and see what is missing. You know your script the best so you should know what's missing and what is giving an error.
PHP:
  // To help debugging with save contents.
const DataManager_makeSaveContents = DataManager.makeSaveContents

  DataManager.makeSaveContents = function () {
    const contents = DataManager_makeSaveContents.call(this)
    console.log(contents)
    return contents
  }
Thread closed IgnoreMe

Original thread: https://forums.rpgmakerweb.com/threads/the-object-function-not-exist-after-load-game.75782/