Hi, I've been trying to port some of my VX Ace scripts over and learning javascript as I go. I think it's going pretty well, though no doubt it could be much, much better. But I've met a problem that has me utterly stumped.
I've created a new camera system that allows the camera to focus on any combination of the player, events, followers, and static points.
It creates an object at "$gameMap._camera" that contains a lot of variables and functions needed for the camera. Since it's contained in $gameMap, it gets included in the save file automatically.
It's all working great, I think, but I've met a problem with saving and loading. After loading the game, functions in _camera seem to become undefined.
For example, here's a console.log of $gameMap before saving.
And here it is after loading
The proto for Game_Camera is empty, all the functions are gone, and it crashes with "
undefined is not a function" immediately after loading. I'm sure I must be missing something obvious but I have no idea what. Help?
The script can be found atÂ
https://dl.dropboxusercontent.com/u/65029315/Camera.js
There's stuff I'm not too happy with in there (storing/restoring backups ended up very clunky) and if you have feedback/pointers for the rest of the script they're welcome. But it's the stuff above that's breaking my back right now.
Thanks.
EDIT: So I found a way to hack it. The proto gets removed when the save extracter overwrites $gameMap, so this...
var gk_camera_DataManager_extractSaveContents = DataManager.extractSaveContents DataManager.extractSaveContents = function(contents) {  var cam = $gameMap._camera.__proto__;  gk_camera_DataManager_extractSaveContents.call(this,contents);  $gameMap._camera.__proto__ = cam;  $gameMap._camera.restoreAfterLoad(); };works. But it does not feel good. It feels bad. So if there's a way I should be going about it (and I don't know why, but things like Game_Map and Game Event properly retain their protos when loaded) then I'd still like to hear it.