G
GhostlyFeline
Guest
I was testing out dynamically creating background layers today, and I noticed a strange behavior. I don't know whether it's an error in my code, or a bug with GMS2. What happens is that the game draws a duplicate sprite. One of the sprites is properly centered around the layer x and y, and the other has the top left corner of the sprite on that point, like this.
Here is my current script for creating a new background layer.
And here's how I'm creating the layer in the game. Note that there should be only one being created.
Did I make a mistake somewhere, or is this a legit bug?
Here is my current script for creating a new background layer.
Code:
/// @description Create a new background layer.
/// @param {int} arrayVal The array value of the background layer.
/// @param {real} layerDepth The depth of the background layer.
/// @param {sprite} bgSprite The sprite to use for the background.
var a = argument0;
var _lDepth = argument1;
//Create the layer.
bgLayerIndex [a] = layer_create( _lDepth, "BackgroundLayer" + string(a) );
bgLayerElement[a] = layer_background_create( bgLayerIndex[a], argument2 );
var _lIndex = bgLayerIndex[a];
var _lElement = bgLayerElement[a];
layer_x(_lIndex, 400);
layer_y(_lIndex, 200);
show_debug_message( "CREATING BACKGROUND LAYER " + string(a) );
Code:
for ( var i = 0; i < 1; i++; )
{
BackgroundLayerCreate(i, -5000 - i, SprPlayerGrazebox);
}