Setting item position in GridContainer for an inventory

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Jefff

Hello,

I’m working on making an inventory using the grid container. So far it works and looks pretty nice but I’ve realized there isn’t an obvious way to set the position of an object in a GridContainer? I’m creating instances of objects as TextureRects and making them children to the GridConatiner.

I’ve also tried to redo this with an ItemList instead of a grid. But this doesn’t appear to have a signal for when the mouse enters an item. (I have custom tooltips that utilize this)

See here: https://i.imgur.com/N5ASrjv.gifv (place holder sprites lol)

Thanks

:bust_in_silhouette: Reply From: kidscancode

GridContainer contents are ordered by child order. You can use Node.add_child_below_node() when you add the item or Node.move_child() to rearrange.

Oh, I see that points be in a better direction.

I suppose this would be pretty useful then:

get_parent().move_child(self, index)
Node — Godot Engine (3.1) documentation in English

Thanks! :slight_smile:

Jefff | 2020-01-09 20:48