TiledBackground multiple frames (like sprite)

For developers using the Construct 2 Javascript SDK

Post » Sat Jan 07, 2012 1:10 pm

So I want to make a plugin that lets you add and switch between frames of a TiledBackground just like a Sprite.

I was hoping this would just be a matter of copy-pasting & tweaking some stuff from Sprite->TiledBackground, but I can't actually seem to find anything in Sprite that tells it to bring up the animation editor and store multiple textures.

It looks like both Sprite and TiledBackground call the same function, yet with different results:
this.instance.EditTexture();

Is there some behind the scenes trickery going on?

My goal is to let players customize the wallpapers on the walls of their in-game shop, which is a TiledBackground. Creating ~20 TiledBackground objects and then using some huge if-chain to spawn/destroy whichever one they select sounds really clumsy. So I thought a more elegant solution would be to add multiple frames to a TiledBackground.

Thoughts?
B
22
S
9
G
5
Posts: 122
Reputation: 5,386

Post » Sat Jan 07, 2012 1:29 pm

In the edittime.js you have to add some flags to let the plugin know it needs to "hook" on those functions.
Check the plugin settings, flags are explained.

Hopefuly it should resolve your issue.Kyatric2012-01-07 13:29:38
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Sat Jan 07, 2012 3:56 pm

Thanks dude! Can't believe I missed that.

BUT it still doesn't work. I tried adding the flags 1 by 1, starting with pf_animated and the animation editor opens but as soon as I add pf_texture (which I need to do the tiling like in tiledbg) the animation editor stops opening. It appears to be you can only have 1 or the other flag active, but not both at the same time. Dang!
B
22
S
9
G
5
Posts: 122
Reputation: 5,386

Post » Sun Jan 08, 2012 6:46 am

EditTexture() opens either the image or animations editor depending on whether pf_texture or pf_animations is set.

pf_texture and pf_animations are mutually exclusive, you can't have both! Your object either has a single texture or a complete animations system, not both.

Your best bet is probably to copy+paste Sprite and change its draw code to match Tiled Background's.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Sun Jan 08, 2012 7:18 am

It wooooooooorks!

well, at least the basic tiling + animation, now I just need to polish it up a little
B
22
S
9
G
5
Posts: 122
Reputation: 5,386

Post » Sun Jan 08, 2012 7:51 am

This sounds interesting, in my current project im using mass amounts of tiled backgrounds (and still a little worried about performance to be honest).

Will using your plugin be much more efficient (cpu wise) than using sprites if you were to add animations? I hope that makes sense.

If so - very cool.GenkiGenga2012-01-08 07:52:28
ImageImage
B
74
S
17
G
6
Posts: 1,039
Reputation: 10,605

Post » Sun Jan 08, 2012 2:46 pm

I'm really not sure about the performance, and I won't be able to release this as a plugin, sorry. I'm only doing this to solve 1 highly specific problem in my game, and it would take really really really to bring it up to a releasable quality level. There's just so much to consider like caching, animation frame sizes, rendering modes, rotation, effects, etcetcetc. As it stands it works for what I want to achieve, but everything else is broken.
B
22
S
9
G
5
Posts: 122
Reputation: 5,386

Post » Sun Jan 08, 2012 4:50 pm

Ah i see, fair enough. Best of luck with it all.GenkiGenga2012-01-08 16:51:58
ImageImage
B
74
S
17
G
6
Posts: 1,039
Reputation: 10,605

Post » Mon Jan 09, 2012 8:35 am

@GenkiGenga tiling via Sprite would be slightly less efficient than tiling with Tiled Background objects, since Sprite has a small overhead for having the animations system.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Mon Jan 09, 2012 11:26 am

Thanks for the input Ashley, been digging around and I think I have a much better understanding of how it all works now (image-wise). I was hoping this plugin might let me do things like animate a waterfall for instance, while still technically being a tiled background for optimisation. No matter though.
ImageImage
B
74
S
17
G
6
Posts: 1,039
Reputation: 10,605

Next

Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 0 guests