Layering Sprites

Discussion in 'Learning Javascript' started by RespectWomen, Apr 24, 2019.

  1. RespectWomen

    RespectWomen Acoustic Child Veteran

    Messages:
    57
    Likes Received:
    14
    Location:
    Brooklyn, New York
    First Language:
    English
    Primarily Uses:
    RMMV
    Trying to draw text over a sprite and it seems the only way to do that would be to make the text itself into a sprite and add it that way, the only problem is whenever it's near the other sprite it's being erased. What's the proper way to layer sprites?

    Here's what I'm working with for context:
    Code:
            this._box = []
            this._boxname =[]
            for (i = 0; i < 5; i++) {
            this._box[i] = new Sprite_Button();
            if (typeof monbox[i] == 'undefined') {this._box[i].bitmap = ImageManager.loadPicture('Icon Panel')} else {this._box[i].bitmap = ImageManager.loadPicture($dataActors[monbox[i]].meta.icon)}
            this.addChild(this._box[i]);
            this._box[i].x = 75 + (161 * i);
            this._box[i].y = 300;
            this._boxname[i] = new Sprite(new Bitmap(this._box[i].x,this._box[i].y));
            this.addChild(this._boxname[i]);
            this._boxname[i].bitmap.outlineColor = 'black';
            this._boxname[i].bitmap.outlineWidth = 4;
            this._boxname[i].bitmap.fontSize =16;
            this._boxname[i].bitmap.drawText('test', 75, 310, 150,0, 'left');
            }
     
    #1
  2. MushroomCake28

    MushroomCake28 KAMO Studio Veteran

    Messages:
    1,747
    Likes Received:
    3,140
    Location:
    Montreal, Canada
    First Language:
    English
    Primarily Uses:
    RMMV
    Is this all happening in the Scene Map? Cause that scene has its own layers and sprite box mask thing. If you're in any other scenes, overlapping shouldn't be a problem (it won't hide other sprites or windows), and the layering entirely depends on the order the sprites/windows were added to the scene.
     
    #2
  3. RespectWomen

    RespectWomen Acoustic Child Veteran

    Messages:
    57
    Likes Received:
    14
    Location:
    Brooklyn, New York
    First Language:
    English
    Primarily Uses:
    RMMV
    It's for a custom menu scene, and they are being added to a window, I think the way I'm doing the text sprite might be the problem? I was having trouble actually getting it on the screen in the first place, I was trying to replicate how the default title screen handles it.


    Code:
            this._boxname[i] = new Sprite(new Bitmap(this._box[i].x,this._box[i].y));
            this.addChild(this._boxname[i]);
            this._boxname[i].bitmap.outlineColor = 'black';
            this._boxname[i].bitmap.outlineWidth = 4;
            this._boxname[i].bitmap.fontSize =16;
            this._boxname[i].bitmap.drawText('test', 75 , 295, 150,0, 'left');
    It specifically is being hidden by other sprites, even the transparency parts

    Edit:
    Figured it out, and for anyone who runs into this later on:
    I had been using new Bitmap wrong thinking it was asking for coordinates, its looking for a width/height.

    This is the way to go:
    this._sprite.bitmap = new Bitmap(Graphics.width, Graphics.height);
     
    Last edited: Apr 24, 2019
    #3
    Eliaquim and MushroomCake28 like this.

Share This Page