How do I Spawn Another 9patch

Get help using Construct 2

Post » Thu May 15, 2014 12:54 am

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
You do not have the required permissions to view the files attached to this post.
B
56
S
15
G
13
Posts: 826
Reputation: 17,645

Post » Thu May 15, 2014 3:37 am

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.
Image
B
75
S
23
G
3
Posts: 673
Reputation: 9,283

Post » Thu May 15, 2014 4:52 am

Does 0 opacity objects slow down your device?
B
56
S
15
G
13
Posts: 826
Reputation: 17,645

Post » Thu May 15, 2014 5:03 am

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.
Last edited by TheDom on Thu May 15, 2014 7:23 pm, edited 1 time in total.
B
75
S
23
G
3
Posts: 673
Reputation: 9,283

Post » Thu May 15, 2014 6:48 am

Oh the limitations of Construct 2. :(
B
56
S
15
G
13
Posts: 826
Reputation: 17,645

Post » Thu May 15, 2014 11:47 am

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)
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Post » Thu May 15, 2014 7:06 pm

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.
B
56
S
15
G
13
Posts: 826
Reputation: 17,645

Post » Thu May 15, 2014 7:19 pm

@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.
B
75
S
23
G
3
Posts: 673
Reputation: 9,283

Post » Thu May 15, 2014 8:00 pm

TheDom wrote:@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
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Post » Thu May 15, 2014 9:12 pm

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

Gah, so much to learn and so little time!
B
56
S
15
G
13
Posts: 826
Reputation: 17,645

Next

Return to How do I....?

Who is online

Users browsing this forum: Construct Monkey, David181, luckyrawatlucky and 6 guests