Trying to display an image behind a scene (help needed)

Warped_Tales

Veteran
Veteran
Joined
Sep 17, 2016
Messages
47
Reaction score
64
First Language
English
Primarily Uses
N/A
Hi,

I'm trying desperately to display an image behind a scene. The scene is a simple one that shows game data to the player but I really want a custom background. I've tried rooting around in the game files and other menu scripts but I'm truly flumoxed!

Any help would be super appreciated. I've included the full scene, and windows, below. Thank you in advance.

-Beth
Code:
//-----------------------------------------------------------------------------
// Scene_EndDay
//-----------------------------------------------------------------------------

function Scene_EndDay() {
    this.initialize.apply(this, arguments);
}

Scene_EndDay.prototype = Object.create(Scene_MenuBase.prototype);
Scene_EndDay.prototype.constructor = Scene_EndDay;

Scene_EndDay.prototype.initialize = function() {
    Scene_MenuBase.prototype.initialize.call(this);
};

Scene_EndDay.prototype.create = function() {
    Scene_MenuBase.prototype.create.call(this);
    this.setBackgroundOpacity(255);
    this.createCommandWindow();
    this.createInfoWindow();
    
};

Scene_EndDay.prototype.createInfoWindow = function() {
    this._infoWindow = new Window_Info(0, 0);
    this._infoWindow.x = 0;
    this.addWindow(this._infoWindow);
};

Scene_EndDay.prototype.stop = function() {
    Scene_MenuBase.prototype.stop.call(this);
    this._commandWindow.close();
};


Scene_EndDay.prototype.createCommandWindow = function() {
    this._commandWindow = new Window_EndDay();
    this._commandWindow.setHandler('EXIT', this.exitmenu.bind(this));
    this.addWindow(this._commandWindow);
};

Scene_EndDay.prototype.exitmenu = function() {
    $gameTemp.reserveCommonEvent(230);
    SceneManager.goto(Scene_Map);
};

Scene_EndDay.prototype.ni = function() {
    this.createniWindow();
};


//-----------------------------------------------------------------------------
// Window_Info
//
// The window for displaying the party's gold.

function Window_Info() {
    this.initialize.apply(this, arguments);
}

Window_Info.prototype = Object.create(Window_Base.prototype);
Window_Info.prototype.constructor = Window_Info;

Window_Info.prototype.initialize = function(x, y) {
    var width = this.windowWidth();
    var height = this.windowHeight();
    Window_Base.prototype.initialize.call(this, 0, y, width, height);
//    this.backOpacity = 50
//    this.drawPicture('EndDay', 0, 0);
    this.refresh();
};

Window_Info.prototype.drawPicture = function(filename, x, y) {   
    var bitmap = ImageManager.loadPicture(filename);   
    this.contents.blt(bitmap, 0, 0, bitmap._canvas.width, bitmap._canvas.height, x, y); 
};

Window_Info.prototype.windowWidth = function() {
    return 1152;
};

Window_Info.prototype.windowHeight = function() {
    return 648;
};

Window_Info.prototype.refresh = function() {
    var x = this.textPadding();
    var width = this.contents.width - this.textPadding() * 2;
    this.contents.clear();
    
    this.drawText($gameSystem.day_week_name(),420 , 152, 1000, 1);
    //this.drawText(weekDay[$gameVariables.value(6)],420 , 152, 1000, 1);
    
    this.changeTextColor(this.textColor(1));
//    this.drawText("World Prosperity:", 0, 110, 1000, 1);
    this.drawText(prosperity(), 420, 200, 1000, 1);
    
//    this.drawText("Purchasing Guild Tax:", 0, 130, 1000, 1);
    this.drawText($gameVariables.value(86) + "%", 420, 248, 1000, 1);
    
//    this.drawText("Interest Rates:", 0, 160, 1000, 1);
    this.drawText($gameVariables.mo + "%", 420, 296, 1000, 1);
    this.changeTextColor(this.textColor(0));
//    this.drawText("Current Loan:", 0, 210, 1000, 1);
    this.drawText($gameVariables.value(83), 420, 392, 1000, 1);
    
    $gameVariables.setValue(84, Math.floor(($gameVariables.value(83) / 100) * $gameVariables.mo));
//    this.drawText("This Weeks Interest:", 0, 260, 1000, 1);
    this.drawText($gameVariables.value(84), 420, 440, 1000, 1);
    this.changeTextColor(this.textColor(15));
    
//    this.drawText("Bank Prosperity:", 0, 360, 1000, 1);
    this.drawText($gameVariables.pp + "%", 900, 172, 1000, 1);
    
//    this.drawText("Bank Strength:", 0, 410, 1000, 1);
    this.drawText($gameVariables.value(89)+ "%", 900, 209, 1000, 1);
    
//    this.drawText("Guards:", 0, 450, 1000, 1);
//    this.drawText($gameVariables.gurd, 200, 450, 1000, 1);
};



Window_Info.prototype.value = function() {
      return $gameVariables.value(1) 
};

Window_Info.prototype.currencyUnit = function() {
    return TextManager.currencyUnit;
};

Window_Info.prototype.open = function() {
    this.refresh();
    Window_Base.prototype.open.call(this);
};



//-----------------------------------------------------------------------------
// Window_EndDay
//

function Window_EndDay() {
    this.initialize.apply(this, arguments);
}

Window_EndDay.prototype = Object.create(Window_Command.prototype);
Window_EndDay.prototype.constructor = Window_EndDay;

Window_EndDay.prototype.initialize = function() {
    Window_Command.prototype.initialize.call(this, 0, 0);
    this.updatePlacement();
    this.openness = 0;
    this.open();
};

Window_EndDay.prototype.windowWidth = function() {
    return 450;//WIN_WIDTH;
};

Window_EndDay.prototype.updatePlacement = function() {
    this.x = 852;
    this.y = 580;
};

Window_EndDay.prototype.makeCommandList = function() {
    
    this.addCommand("Carry on...", 'EXIT');
    

};


////////////////////////////INFO STUFF



var prosperity = function() {
    if($gameVariables.value(99) < 21) {
        var prosp = "In Starvaton";
        $gameVariables.mo = 0.18;
        $gameVariables.setValue(86, 90);
        $gameVariables.gurd = "can be bribed";
        return prosp;
    };
    if($gameVariables.value(99) < 41) {
        var prosp = "On the Breadline";
        $gameVariables.mo = 0.22;
        $gameVariables.setValue(86, 80);
        $gameVariables.gurd = "can be bribed";
        return prosp;
    };
    if($gameVariables.value(99) < 61) {
        var prosp = "Very Poor";
        $gameVariables.mo = 0.26;
        $gameVariables.setValue(86, 70);
        $gameVariables.gurd = "can be bribed";
        return prosp;
    };
    if($gameVariables.value(99) < 81) {
        var prosp = "Standard";
        $gameVariables.mo = 0.3;
        $gameVariables.setValue(86, 60);
        $gameVariables.gurd = "can be bribed";
        return prosp;
    };
    if($gameVariables.value(99) < 101) {
        var prosp = "A few Luxuries";
        $gameVariables.mo = 0.36;
        $gameVariables.setValue(86, 50);
        $gameVariables.gurd = "cannot be bribed";
        return prosp;
    };
    if($gameVariables.value(99) < 121) {
        $gameVariables.mo = 0.42;
        $gameVariables.setValue(86, 40);
        var prosp = "Wealthy";
        $gameVariables.gurd = "cannot be bribed";
        return prosp;
    };
    if($gameVariables.value(99) < 500) {
        $gameVariables.mo = 0.48;
        $gameVariables.setValue(86, 30);
        var prosp = "Rich";
        $gameVariables.gurd = "cannot be bribed";
        return prosp;
    };
    if($gameVariables.value(99) > 499) {
        var prosp = "Free";
        $gameVariables.mo = 0;
        $gameVariables.setValue(86, 20);
        $gameVariables.gurd = "cannot be bribed";
        return prosp;
    };
        
};
 

Clock Out

Veteran
Veteran
Joined
Jun 14, 2016
Messages
92
Reaction score
45
First Language
English
Primarily Uses
RMMV
I looked through Scene_Title and put this together.
Code:
// Preload the image(s) when the game starts.

var backgrounds = {};

// Image must be in png format. The first argument is the path and
// the second is the file name.

backgrounds.testScene = ImageManager.loadBitmap(
    "img/example/",
    "pic",
    0,
    true
);

// Example window.

function aWin() {
    "use strict";

    var win = Object.create(Window_Selectable.prototype);

    win.initialize(12, 12, 300, win.lineHeight() * 2);

    return win;
}

// Example scene. Open the console and type
// SceneManager.push(testScene) to run.

function testScene() {
    "use strict";

    var scene = Object.create(Scene_MenuBase.prototype);

    // Replace createBackground with a method that uses the picture.

    scene.createBackground = function () {
        // Create sprite.

        var background = new Sprite(backgrounds.testScene);

        // Center the sprite.

        background.x = Graphics.boxWidth / 2;
        background.y = Graphics.boxHeight / 2;
        background.anchor.x = 0.5;
        background.anchor.y = 0.5;

        // Add the background to the scene.

        scene.addChild(background);
    };

    scene.create = (function (original) {
        return function () {
            var win;

            original.call(scene);

            win = aWin();
            win.drawText("Cancel to exit.", 0, 0, 300, "left");
            win.setHandler("cancel", function () {
                scene.popScene();
            });
            win.activate();

            scene.addWindow(win);
        };
    }(scene.create));

    scene.initialize();

    return scene;
}
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Are there any vocalists on RPG Maker Forums that would want to sing together in a group, duet or make a whole channel together?
Here it is in all its leggy glory! I apologize in advance.
Suggestion for the name for the new RM, RPG Maker Re-MV (Re-Mastered Version)
A guide on Furry Potatoes.

Forum statistics

Threads
98,175
Messages
950,090
Members
129,473
Latest member
Soulbanana
Top