How do I swap 9-patch image with a different one?

Get help using Construct 2

Post » Mon Jan 12, 2015 7:39 pm

9-patch only has one frame, unlike sprites which allow multiple frames..
How would I change the image of a 9-patch so that I can switch between them at runtime?
if it can't be done with built-in methods, are there any plugins that solve this?
B
43
S
19
G
65
Posts: 1,105
Reputation: 37,949

Post » Mon Jan 12, 2015 8:04 pm

There is always the option of using several 9-patch objects with different images and regrouping them in a family for events purpose.
B
69
S
28
G
24
Posts: 977
Reputation: 18,739

Post » Mon Jan 12, 2015 8:13 pm

I have the 9-patch in a container.. so there will be multiple instances of it. I don't think putting them in a family will solve the issue.
B
43
S
19
G
65
Posts: 1,105
Reputation: 37,949

Post » Mon Jan 12, 2015 8:18 pm

It would have, if not for the "being in a container" part. I don't see how you'll be able to do what you want without @Ashley adding some sort built-in way of having multiple frames for a 9-patch or a "Load image from url" thing.
B
69
S
28
G
24
Posts: 977
Reputation: 18,739

Post » Mon Jan 12, 2015 8:31 pm

hm.. yea.. I think loading from url wouldn't work either because it would probably end up changing all the instances as well if they all share the same image. There'd have to be some built in support for multiple frames I guess.
I'll have to experiment and see if I can work with using multiple separate 9-patches somehow. Will require more tedious management unfortunately. :\
B
43
S
19
G
65
Posts: 1,105
Reputation: 37,949

Post » Mon Apr 03, 2017 10:29 pm

unfortunately, I still need this. :(
2 years later no solutions.
B
43
S
19
G
65
Posts: 1,105
Reputation: 37,949

Post » Mon Apr 03, 2017 11:04 pm

Stack two 9patches on top of each other in a container. Toggle visibility.
Mistakes were made.
B
51
S
25
G
107
Posts: 1,581
Reputation: 60,458

Post » Mon Apr 03, 2017 11:04 pm

I have a 9patch that is part of a container with another 9patch and a spritefont.
I have 25 layers, and a container on each one.
In the events I pick the 9patch by checking if it is on a layer.
When one is picked, the other objects in the container are also picked.
now..
I want to be able to have 25 different looking 9patches.
It would be simple if I could just store these in different animations/frames. I would simply set the animation/frame in the editor.
Unfortunately I can't do this.
So, the only way is to create 25 9patches.. but they need to be in a container too! So each of those have to have another 25 other 9patches and 25 other spritefonts!
Not to mention that I need 25 times the number of events! because I can't put them in a family. If I did, I would need to put the spritefont and other 9patches in other families too, and then pick each one based on the other that is picked.. so it creates a mess of events!!

This is all because I can't have 9patches with animations/frames..
The same can be said of tiledbackgrounds.

:(

@Ashley
B
43
S
19
G
65
Posts: 1,105
Reputation: 37,949

Post » Mon Apr 03, 2017 11:14 pm

In that case, where you have a more involved feature, it would probably be worth building your own 9-patch like container out of sprites. It shouldn't be too difficult (one set of events to pin to imagepoints basically).

The functionality can be recreated with events, just like most behaviors and features in Construct. Particles is another object that comes to mind where I regularly just use sprites and events.

EDIT: Note that I'm all for updating the 9-patch object. Rotations please! =)
Mistakes were made.
B
51
S
25
G
107
Posts: 1,581
Reputation: 60,458

Post » Mon Apr 03, 2017 11:33 pm

@oosyrag , unfortunately sprites don't tile/repeat. I could use a tilebackground, but those don't have animations/frames, so that would be 4*4*25 tiledbackground objects(for each side of the 9patch area)!! So using sprites/tiledbackgrounds is out of the question.
:(
B
43
S
19
G
65
Posts: 1,105
Reputation: 37,949

Next

Return to How do I....?

Who is online

Users browsing this forum: tarek2 and 57 guests