How to controll in-game menu with different object types?

0 favourites
  • 7 posts
From the Asset Store
Adjusting the game screen for different resolutions (Letterbox scale)
  • I have an in-game menu that is made up of Sprites, Tiled Backgrounds and Text objects.

    The menu is created using a loop and math in order to make it appear correctly, even with transparency.

    When I need to hide the menu, I have to change the opacity or change their layer.

    I tried to use a container, but it seems to always place the objects in the middle of the Parent object or on it's origin point.

    Plus it seems you can't preset instances of an object in a container.

    I was thinking of using a family with an ID Variable, but you can't have different types of objects in a family.

    The only thing I can think of is making three different families with ID Variables in order to control the menu.

    I am only curious if there Is a better way, or if I am missing something on containers?

    Maybe show me a plug-in that would do this.

    • Thanks in advance
  • It would be good to know exactly what you need to control. Can you share a capx or explain in more detail, please?

  • I think I edited the post before you posted.

    I am wanting to know how to control Sprites, Tiled Backgrounds and Text objects together.

    I think the only way is to have 3 families with an ID Variable.

    I know different objects have different actions, but I only need to change opacity or layer.

    I don't fully understand containers, because it seems you can only create a container before run time.

    Unless I am missing something, it seems it is a really limited behavior.

    I am only curious if making three families is the only way, or if there is another method I am missing.

  • Containers only mean that a bunch of objects will be created and destroyed together. It doesn't position then relative to one another (you have to do that separately) and it doesn't "link" their stats together (you'll have to set opacity, visibility or layer for each of them separately).

    If you have several menus that use similar elements, the way to go is to create a function that dynamically creates the objects and sets them up. If you have fewer menus and limited variation, maybe a better approach is to have them pre built and control only visibility dynamically.

    It's hard to tell which approach is best without seeing a capx or knowing exactly your use of menus in this specific app/game.

    Hope this sheds some light on the issue.

    Cheers.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • When I create a container with different types of objects, the objects will always be created at the source point of the parent object like you said.

    The solution that I do is:

    Container ("Father", "Son1", "Son2")

    When the object "Father" is created:

    Set Son1.X = Pai.X + 20

    Set Son2.Y = Pai.Y + 100

    I think it's not the best solution for that, but it works for me. Good luck.

  • Hi Unconnected ,

    further responding to duditon 's answer, you could also try and set your containers elements origin points to position your containers elements on spawn.

    For example, if you have object A and B in a container, and you want object B to be 100 pixels south of object A, then simply put object B's origin point 100 pixels above its center, and the object will spawn 100 pixels south of where it "should" have spawned.

    This can help you a lot positioning everything in one go, without having to have any events positioning stuff for you, and also retains every object's position, even on object destruction. The problem is that it's tedious to set up properly if you have lots of objects in your container.

    ________________

    Another solution could be the one I use in my game in progress, which have about half a dozen menus stacked on top of each other : Put every menu in it's own layer (1 layer per menu), set them up how you want them to be set up, and make them appear/disappear by making the layer appear/disappear.

    The only problem with this is that every clickable object will still be clickable , even when invisible. You will only need to make these objects unclickable by using a boolean , off when the layer is invisible, and on when the layer is visible. Pretty simple stuff.

    Hope this helped !

  • I thought about moving the child object after creating the Parent, but I didn't know how to create an instance child for the container and still have it in the container.

    Making 3 families would have been near useless, because I would still have to check for a variable, nearly the same with objects without a family.

    I was only asking how to approach something, I didn't want to post my whole project.

    A capx would have been near empty with only a Tiled Background, a Few Sprites, and a few text objects.

    I found a good plug-in that solved the problem.

    It is called Pin+

    I was using it wrong so I thought it didn't work anymore.

    Thanks again.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)