MZ - Is there any way to change priority of a picture?

● ARCHIVED · READ-ONLY
Started by Decinbr 11 posts View original ↗
  1. Hi.
    My enemies were made by pictures, but now I want to make them move.
    I did, but I forgot the detail that the picture above has the lowest priority, so it ends up being under the enemy.
    Is there any code or plugin that modifies the picture priority?
    Thanks
  2. I don't understand what you mean. Are you talking about enemies in the world map or in battle?
  3. ShiningPhoibe said:
    I don't understand what you mean. Are you talking about enemies in the world map or in battle?
    Map.
    Im using pictures like...
    Show picture 1 Slime idle 1
    Wait 8 frames
    Show picture 1 Slime idle 2
    Wait 8 frames
    So on...
  4. Showing picture isn't the intended way to have enemies. You can't move them around as you want.
    You can use events and sprite sheets for that purpose. I could demonstrate if you say which maker you use.
  5. You could modify the z coordinate of the Sprite_Picture instance.
  6. Trihan said:
    You could modify the z coordinate of the Sprite_Picture instance.
    How to do that?
  7. Decinbr said:
    Is there any code or plugin that modifies the picture priority?
    Like this?

    JavaScript:
    var sprites = SceneManager._scene._spriteset._pictureContainer.children;
    var index = 4, newIndex = 5;
    var sprite = sprites[index];
    sprites.splice(index, 1);
    sprites.splice(newIndex,0,sprite);
    Keep in mind index of the sprite in the array starts with 0 not 1
    So when starting index 4 is actually picture 5.
    So that above code moves picture 5 above picture 6.

    JavaScript:
    var sprites = SceneManager._scene._spriteset._pictureContainer.children;
    var index = 5, newIndex = 4;
    var sprite = sprites[index];
    sprites.splice(index, 1);
    sprites.splice(newIndex,0,sprite);
    This would then reverse the above code if needed.

    That's what worked for me in my tests..
    (I couldn't get results from simply changing '_zIndex' of the sprite)
  8. ct_bolt said:
    Like this?

    JavaScript:
    var sprites = SceneManager._scene._spriteset._pictureContainer.children;
    var index = 4, newIndex = 5;
    var sprite = sprites[index];
    sprites.splice(index, 1);
    sprites.splice(newIndex,0,sprite);
    Keep in mind index of the sprite in the array starts with 0 not 1
    So when starting index 4 is actually picture 5.
    So that above code moves picture 5 above picture 6.

    JavaScript:
    var sprites = SceneManager._scene._spriteset._pictureContainer.children;
    var index = 5, newIndex = 4;
    var sprite = sprites[index];
    sprites.splice(index, 1);
    sprites.splice(newIndex,0,sprite);
    This would then reverse the above code if needed.

    That's what worked for me in my tests..
    (I couldn't get results from simply changing '_zIndex' of the sprite)
    Thank you so much, i gonna try today
  9. Decinbr said:
    Thank you so much, i gonna try today
    No prob. Hope it works as needed for ya. :)
  10. ct_bolt said:
    Like this?

    JavaScript:
    var sprites = SceneManager._scene._spriteset._pictureContainer.children;
    var index = 4, newIndex = 5;
    var sprite = sprites[index];
    sprites.splice(index, 1);
    sprites.splice(newIndex,0,sprite);
    Keep in mind index of the sprite in the array starts with 0 not 1
    So when starting index 4 is actually picture 5.
    So that above code moves picture 5 above picture 6.

    JavaScript:
    var sprites = SceneManager._scene._spriteset._pictureContainer.children;
    var index = 5, newIndex = 4;
    var sprite = sprites[index];
    sprites.splice(index, 1);
    sprites.splice(newIndex,0,sprite);
    This would then reverse the above code if needed.

    That's what worked for me in my tests..
    (I couldn't get results from simply changing '_zIndex' of the sprite)
    Worked!!!
    Worked!!!
    Thank you so much man!
    You are a hero!!
  11. 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.