Properly defined but not showing itself

Milena

The woman of many questions
Veteran
Joined
Jan 26, 2014
Messages
1,281
Reaction score
106
First Language
Irish
Primarily Uses
N/A
I have made this sample code in Spriteset_Map and Game_System, where I wanted to place a sample image on the screen that the character can step unto:

// Ground OverlaySpriteset_Map.prototype.ground_overlay;Game_System.prototype.ground_overlay_name = null;Game_System.prototype.ground_overlay_opacity = 0;Game_System.prototype.ground_overlay_x = 0;Game_System.prototype.ground_overlay_y = 0;ImageManager.loadOverlay = function(filename, hue) { return this.loadBitmap('img/overlays/', filename, hue, false);}Spriteset_Map.prototype.initialize = function() { Spriteset_Base.prototype.initialize.call(this); this.ground_overlay = null; $gameSystem.ground_overlay_name = null; $gameSystem.ground_overlay_opacity = 255; $gameSystem.ground_overlay_x = 0; $gameSystem.ground_overlay_y = 0; };Spriteset_Map.prototype.createGroundOverlay = function() { this.ground_overlay = new Sprite(); this.ground_overlay.bitmap = ImageManager.loadOverlay($gameSystem.ground_overlay_name); this.ground_overlay.opacity = $gameSystem.ground_overlay_opacity; this.ground_overlay.z = 10; this._tilemap.addChild(this.ground_overlay); console.log(this.ground_overlay); };Game_System.prototype.call_ground_overlay = function(ground_overlay_name, ground_overlay_opacity, x, y) { this.ground_overlay_name = ground_overlay_name; this.ground_overlay_opacity = ground_overlay_opacity; this.ground_overlay_x = x; this.ground_overlay_y = y;}Spriteset_Map.prototype.updateGroundOverlay = function() { this.ground_overlay.x = this.ground_overlay_x; this.ground_overlay.y = this.ground_overlay_y; }Spriteset_Map.prototype.createLowerLayer = function() { Spriteset_Base.prototype.createLowerLayer.call(this); this.createParallax(); this.createTilemap(); // create ground layer this.createGroundOverlay(); this.createCharacters(); this.createShadow(); this.createDestination(); this.createWeather();};Spriteset_Map.prototype.update = function() { Spriteset_Base.prototype.update.call(this); this.updateTileset(); this.updateParallax(); this.updateGroundOverlay(); this.updateTilemap(); this.updateShadow(); this.updateWeather();}; 
It keeps saying everything about the functions I made is undefined, such as the x property being null, but they are referenced in Game_System, yet I am sure I have declared them quite well, or did I miss something? Also, I notice that when I add something into the spriteset map, it doesn't update right away, you'd have to go to the menu then go back to the map so everything inside the map would be updated. Is there a workaround on this?

the script command I suppose to want to use is:

$gameSystem.call_ground_overlay('Brick', 255, 0, 0);so the ground layer appears but it doesn't because of the error I am getting. Anything wrong with my code?
 
Last edited by a moderator:

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
can you show the error code ? 

it's better to know wich lines are getting the error
 

Milena

The woman of many questions
Veteran
Joined
Jan 26, 2014
Messages
1,281
Reaction score
106
First Language
Irish
Primarily Uses
N/A
It's on this part:

Code:
Spriteset_Map.prototype.updateGroundOverlay = function() {    this.ground_overlay.x = this.ground_overlay_x;  this.ground_overlay.y = this.ground_overlay_y;  }
 

Quxios

Veteran
Veteran
Joined
Jan 8, 2014
Messages
1,055
Reaction score
785
First Language
English
Primarily Uses
RMMV
Well looking at your code I can't find the properties "ground_overlay_x" or "ground_overlay_y" in your Spriteset_Map, so I'm assuming it's suppose to be $gameSystem not this.
 

Milena

The woman of many questions
Veteran
Joined
Jan 26, 2014
Messages
1,281
Reaction score
106
First Language
Irish
Primarily Uses
N/A
Tried to change it to gameSystem and the error is gone, but this time it says there's an error on the eval.
 

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
hum sprite manipulation can be tricky to do

if I understand you try to do a sprite who overlay on the maps...likes fogs or ect?  or you try to do parrallaxed mappings ? 

I am just asking for be sure of what you want to do

but sometime it's better to do a external function who will handle's this so it's will avoid any kind of issue's like this 
 

Necromus

Veteran
Veteran
Joined
Mar 14, 2012
Messages
490
Reaction score
61
First Language
German
Primarily Uses
Sorry to hyjack your thread a bit, but I've just done some basic JS through codeacademy so I can surely read all the code, just some parts are escaping me atm.

Like its been said already, I can see that you wan't to use the same properties for both Spriteset_Map and Game_System, with them having any connection/inheritance, that surely can't work.

But what I can't understand either is JS version of 'initialize'.

Does it call itself? If not, when does it happen, I can't seem to find anything about that.
 
Last edited by a moderator:

Jeremy Cannady

Coldfire
Veteran
Joined
Oct 25, 2015
Messages
449
Reaction score
268
First Language
English
When you create something you call the initialize function. The update function will run automatically every frame. So if you don't call the initialize then it won't run that function.
 

Milena

The woman of many questions
Veteran
Joined
Jan 26, 2014
Messages
1,281
Reaction score
106
First Language
Irish
Primarily Uses
N/A
Hi everyone, the problem was solved, thanks a lot.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,049
Members
137,569
Latest member
Shtelsky
Top