Adding Background image from pictures folder

So I have the base portion of the script to draw a background I am just unsure on how to add an image from the pictures folder.

Code:

Spriteset_CardBattle.prototype.createBackground = function() {
this._backgroundSprite = new Sprite();
this._backgroundSprite.bitmap = SceneManager.backgroundBitmap();
this._baseSprite.addChild(this._backgroundSprite);

Picture Location:

img/pictures/background

Any help is greatly appreciated.
You have to set the bitmap to ImageManager.loadPicture(filename, hue)
Like this?
this._backgroundSprite.image = ImageManager.loadPicture(img/pictures/backgroun, 100);
No, like this:

Code:
this._backgroundSprite.bitmap = ImageManager.loadPicture(filename, hue);

For the filename, no need to put the full path, you just need to to put the file name.
As for before, I'm not sure why you called the SceneManager.backgroundBitmap(). That's used to create a sprite with a snapshot of the game as an image (like in the Menu Scene for example). If you want to display an image on top of a game snapshot, you need to create 2 different sprites.
So this loads it straight from the pictures folder or do I put it in the system folder? Sorry I'm still very new to this.
So this loads it straight from the pictures folder or do I put it in the system folder? Sorry I'm still very new to this.

This loads it directly from the pictures folder. If you want it to load from the system folder, you would use ImageManager.loadSystem instead.
When I do it says that the background is not defined.
Try adding this to your scene in the create function:

Code:
this._sprtBack = new Sprite_Base();
this._sprtBack.bitmap = ImageManager.loadPicture(filename, 0);
this.addChild(this._sprtBack);

Of course, replace the filename by the actual filename of the picture.
Still showing not defined. I'll dig a little deeper, it may be pulling the error from somewhere else.
Still showing not defined. I'll dig a little deeper, it may be pulling the error from somewhere else.

Hmm, that's weird. Could you post the error in the console?

And where did you put the code?
Here it is in code


//-----------------------------------------------------------------------------
// Spriteset_CardBattle
//

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

Spriteset_CardBattle.prototype = Object.create(Spriteset_Base.prototype);
Spriteset_CardBattle.prototype.constructor = Spriteset_CardBattle;

Spriteset_CardBattle.prototype.initialize = function() {
Spriteset_Base.prototype.initialize.call(this);
};

Spriteset_CardBattle.prototype.createLowerLayer = function() {
Spriteset_Base.prototype.createLowerLayer.call(this);
this.createBackground();
this.createBattleField();
this.createTurnCursor();
this.createPlayerCards();
this.createEnemyCards();
this.createNumberSprites();
};

Spriteset_CardBattle.prototype.createBackground = function() {
this._sprtBack = new Sprite_Base();
this._sprtBack.bitmap = ImageManager.loadPicture(stage, 0);
this.addChild(this._sprtBack);
};

Spriteset_CardBattle.prototype.createBattleField = function() {
var width = Graphics.boxWidth;
var height = Graphics.boxHeight;
var x = (Graphics.width - width) / 2;
var y = (Graphics.height - height) / 2;
this._battleField = new Sprite();
this._battleField.setFrame(x, y, width, height);
this._battleField.x = x;
this._battleField.y = y;
this._baseSprite.addChild(this._battleField);
};

Spriteset_CardBattle.prototype.createTurnCursor = function() {
this._turnCursorSprite = new Sprite_TurnCursor();
this._baseSprite.addChild(this._turnCursorSprite);
};

Spriteset_CardBattle.prototype.createPlayerCards = function() {
this._playerCardSprites = [];
var playerDeck = $gameCardBattle.playerDeck();
for (var i = 0; i < playerDeck.size(); i++) {
this._playerCardSprites = new Sprite_Card(playerDeck.card(i), false);
this._baseSprite.addChild(this._playerCardSprites);
}
var itemCard = playerDeck.itemCard();
if (itemCard) {
var sprite = new Sprite_Card(itemCard, false);
this._playerCardSprites.push(sprite);
this._baseSprite.addChild(sprite);
}
};

Spriteset_CardBattle.prototype.createEnemyCards = function() {
this._enemyCardSprites = [];
var enemyDeck = $gameCardBattle.enemyDeck();
for (var i = 0; i < enemyDeck.size(); i++) {
var hide = false;
this._enemyCardSprites = new Sprite_Card(enemyDeck.card(i), hide);
this._baseSprite.addChild(this._enemyCardSprites);
}
var itemCard = enemyDeck.itemCard();
if (itemCard) {
var sprite = new Sprite_Card(itemCard, false);
this._enemyCardSprites.push(sprite);
this._baseSprite.addChild(sprite);
}
};

Spriteset_CardBattle.prototype.createNumberSprites = function() {
var pos = TMPlugin.Card.NumberPositions[0];
this._playerHpSprite = new Sprite_Number(pos[0], pos[1], 256, 128, 120, '#000000', 3, '#ffffff');
this._baseSprite.addChild(this._playerHpSprite);
pos = TMPlugin.Card.NumberPositions[1];
this._playerAtkSprite = new Sprite_Number(pos[0], pos[1], 128, 64, 60, '#ff0000', 3, '#000000');
this._baseSprite.addChild(this._playerAtkSprite);
pos = TMPlugin.Card.NumberPositions[2];
this._enemyHpSprite = new Sprite_Number(pos[0], pos[1], 256, 128, 120, '#000000', 3, '#ffffff');
this._baseSprite.addChild(this._enemyHpSprite);
pos = TMPlugin.Card.NumberPositions[3];
this._enemyAtkSprite = new Sprite_Number(pos[0], pos[1], 128, 64, 60, '#ff0000', 3, '#000000');
this._baseSprite.addChild(this._enemyAtkSprite);
if ($gameCardBattle.playerDeck().itemCard()) {
pos = TMPlugin.Card.PlayerItemCardPosition;
this._playerChargeTimeSprite = new Sprite_Number(pos[0], pos[1], 96, 48, 45, '#0000ff', 3, '#ffffff');
this._baseSprite.addChild(this._playerChargeTimeSprite);
}
if ($gameCardBattle.enemyDeck().itemCard()) {
pos = TMPlugin.Card.EnemyItemCardPosition;
this._enemyChargeTimeSprite = new Sprite_Number(pos[0], pos[1], 96, 48, 45, '#0000ff', 3, '#ffffff');
this._baseSprite.addChild(this._enemyChargeTimeSprite);
}
};

Spriteset_CardBattle.prototype.update = function() {
Spriteset_Base.prototype.update.call(this);
this.updateNumberSprites();
};

Spriteset_CardBattle.prototype.updateNumberSprites = function() {
this._playerHpSprite.setNumber($gameCardBattle.playerDeck().hpDraw);
this._playerAtkSprite.setNumber($gameCardBattle.playerDeck().atkDraw);
this._enemyHpSprite.setNumber($gameCardBattle.enemyDeck().hpDraw);
this._enemyAtkSprite.setNumber($gameCardBattle.enemyDeck().atkDraw);
if (this._playerChargeTimeSprite) {
this._playerChargeTimeSprite.visible = this._playerCardSprites[this._playerCardSprites.length - 1].isGray();
this._playerChargeTimeSprite.setNumber($gameCardBattle.playerDeck().chargeTime - 1);
}
if (this._enemyChargeTimeSprite) {
this._enemyChargeTimeSprite.visible = this._enemyCardSprites[this._enemyCardSprites.length - 1].isGray();
this._enemyChargeTimeSprite.setNumber($gameCardBattle.enemyDeck().chargeTime - 1);
}
};


This is the error



rpg_managers.js:1756 ReferenceError: stage is not defined
at Spriteset_CardBattle.createBackground (TMCard.js:1995)
at Spriteset_CardBattle.createLowerLayer (TMCard.js:1985)
at Spriteset_CardBattle.Spriteset_Base.initialize (rpg_sprites.js:2124)
at Spriteset_CardBattle.initialize (TMCard.js:1980)
at new Spriteset_CardBattle (TMCard.js:1973)
at Scene_CardBattle.createSpriteset (TMCard.js:2818)
at Scene_CardBattle.createDisplayObjects (TMCard.js:2812)
at Scene_CardBattle.create (TMCard.js:2808)
at Function.SceneManager.changeScene (rpg_managers.js:1810)
at Function.SceneManager.updateMain [as updateMainFluidTimestep] (rpg_managers.js:1789)
The name of the picture you want to load must be in quotes, because it is a string, not a variable.

So if you want to load:
project/img/pictures/my-totally-awesome-picture.png

The code is:
Code:
this._sprtBack.bitmap = ImageManager.loadPicture("my-totally-awesome-picture", 0);
The name of the picture you want to load must be in quotes, because it is a string, not a variable.

So if you want to load:
project/img/pictures/my-totally-awesome-picture.png

The code is:
Code:
this._sprtBack.bitmap = ImageManager.loadPicture("my-totally-awesome-picture", 0);
You were right Thanks so much guys.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/adding-background-image-from-pictures-folder.96934/