0 Favourites

How do I Spawn Another 9patch

  • Hey there,

    I am trying to create a function, that when called, will spawn the proper GUI and all the other info required for that window. Unfortunately, there seems to be no way to spawn an object with a function. There is of course controlling the opacity of the object and having it already placed in the correct spot but I would prefer to control it by spawning and destroying, as needed.

    Can anyone shed some light on how I would do this?

    Thank You

  • I see what you're saying however you can create more than one 9patch and rename them. You can put the on separate layers and make them invisible. You can keep the code that controls them in groups that you can use the System object to disable and enable them as they become visible and invisible without destroying them.

  • Does 0 opacity objects slow down your device?

  • Yes if your using it for the above example that I outlined. It's better to make them invisible. You can keep them Off screen and use set position to move it to X and Y coordinates you want and the back Off screen again.

  • Oh the limitations of Construct 2.

  • You could also use the system action "Create object".

    Normally creating and destroying object without reusing them is not that great for HTML5, but C2 behind the scene recycles the objects, however I still think it is better to have the window created once and to reuse it, but that is not a big deal at the end for that.

    EDIT: Also opacity = 0 isn't slowing down the device more than opacity = 100 I think, but setting it to invisible tells C2 to skip entirely the drawing on screen, which is better

    At the end C2 isn't that limited, the only limitations really seems to be the HTML5 ones, and all in all it is still easier in C2 since it helps a lot and is already well optimised for a lot of things (like the recycling of objects to compensate the lack of direct memory management of javascript, or the bounding box collision checks to prevent doing too many precise collisions checks if not needed)

  • I have been using the Visible and Invisible triggers and they haver been working quite well. I'm so used to C++ where you gotta make sure you clean up after yourself.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Aphrodite I was going to suggest that but tried it first. In the case of the 9Patch object you can neither spawn nor use the create object method but I agree, C2 is not very limited. In fact it is only as limited as your imagination and experience.

  • Aphrodite I was going to suggest that but tried it first. In the case of the 9Patch object you can neither spawn nor use the create object method but I agree, C2 is not very limited. In fact it is only as limited as your imagination and experience.

    I just tried, and I used create object to create a 9patch, and it worked, and by using a container between a 9patch and the other elements of the window, and by placing them with an event starting by "9Patch: on created", it should work just fine

  • I was going the way of "Spawn another object" instead of using "System > Create Object".

    Gah, so much to learn and so little time!

  • Your right Aphrodite ! I went back, tried it again and it worked. I must done something wrong and didn't realize it but,

    that will definitely come in handy too. Thanks for that.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
99 10,136
karshinkoff's avatar
karshinkoff
Unread hot topic
56 4,728
MPPlantOfficial's avatar
MPPlantOfficial
Unread hot topic
0 Favourites
Why is Stencyl doing better?
44 16,852
Potato's avatar
Potato