[Solved]Remembering picked textures

For questions about using Classic.

Post » Tue Nov 27, 2012 9:47 am

Back again. Seems like I only ever make it a step or two before I have to come back...

I tried searching and couldn't find anything like this.

In short, r0johound showed me a way to reuse tiles in my tile editor so everytime you move it recycles the ones from the bottom and puts them up top etc...

This solved the issue of larger maps slowing down due to all of the images.

A little further along I decided to come up with a way to import your own tiles... I used the method outlined here:

[QUOTE]
Method#3
Use a different instance of a tiledBG object for each tile. Adding another tile at runtime is as simple as creating another instance and loading the texture.   Keeping the actual tiles as sprites you can select the texture by giving it the texture of one of the tiledBG instances using this plugin http://www.scirra.com/forum/plugin-texture-setter_topic43143.html.

Here is an example:
http://dl.dropbox.com/u/5426011/examples15/tiles_TextureSetter.zip
[/QUOTE]

Works great in theory. That example makes it look so easy! But it doesn't work with the tile-recycling method somehow. I'm using the exact same objects, just instead of changing animation frame to change the image I'm putting one overtop with texture setter. But everytime you move away and come back it clears the tiles.

Here's a link to my .cap

Please take a look and help me out here!

https://dl.dropbox.com/u/69407974/texture%20saving%203.capcrowtongue2012-12-30 00:29:04
B
7
S
2
Posts: 123
Reputation: 1,061

Post » Tue Nov 27, 2012 10:10 am

Hmm I've not tested this but perhaps another method is to use TiledBG objects to load each texture once, then for each sprite tile you can check the variable ("TileType" or similar) and use TextureSetter to overwrite the sprite texture with the respective TiledBG texture.
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009

Post » Tue Nov 27, 2012 6:24 pm

That's actually exactly what I'm going for (unless I've misunderstood you.)

At this point it's one of those things where I'm convinced it has to be the best way of doing this too, so I don't want to switch unless absolutely necessary.

B
7
S
2
Posts: 123
Reputation: 1,061

Post » Fri Nov 30, 2012 2:04 pm

Bump

Still not any further with this
B
7
S
2
Posts: 123
Reputation: 1,061

Post » Fri Nov 30, 2012 7:44 pm

The texture setter sets the texture until something else changes it back to it's original texture.

I can't open the file you posted, but you could add an event like this to set the texture every frame:
+ System: For each tex
+ tile: Value 'tex' Equal to tex ('id')
-> TextureSetter: Give tile the texture from tex
B
79
S
24
G
54
Posts: 4,743
Reputation: 40,749

Post » Sun Dec 02, 2012 10:24 pm

It's good to see that I'm thinking more along these lines. This was actually one of the first things I tried, and it doesn't work. It will sometimes remember one tile, but that tile will be repeated across the map since the method of clearing the screen you helped me implement basically just recycles tiles.

I think I have to go back to the drawing board and reimplement that system.
B
7
S
2
Posts: 123
Reputation: 1,061

Post » Tue Dec 04, 2012 7:58 am

Ok so...

If I were to get rid of Event #5

[QUOTE]+For "Y" from 0 to 24
+For "X" from 0 to 36
->create object "tile" on layer1 at ((loopindex("X")*32),((loopindex("Y")*32)
->Tile: set 'x' to loopindex("X")
->Tile: set 'y' to loopindex("Y")
->Tile: set 'tile' to -1
[/QUOTE]
and my events for scrolling the map...
[QUOTE]
+While
+Tile: X Less than ScrollXLeft -16
->Tile:set 'x' to 'x' + 37
->Tile:set X to .x +37*32
->Tile:set 'tile' to -1

+While
+Tile: X Greater than ScrollXRight + 16
->Tile:set 'x' to 'x' - 37
->Tile:set X to .x -37*32
->Tile:set 'tile' to -1

+While
+Tile: X Less than ScrollYTop - 16
->Tile:set 'x' to 'x' + 25
->Tile:set X to .x +25*32
->Tile:set 'tile' to -1

+While
+Tile: X Greater than ScrollYBottom+ 16
->Tile:set 'x' to 'x' - 25
->Tile:set X to .x -25*32
->Tile:set 'tile' to -1
[/QUOTE]
then add in the event that r0johound suggested above...

[QUOTE]
+ System: For each tex
+ tile: Value 'tex' Equal to tex ('id')
-> TextureSetter: Give tile the texture from tex
[/QUOTE]
It works fine! Unfortunately when I create a map as big as 200 x 200 tiles or bigger it gets incredibly bogged down, which is why these events are here in the first place. If I take them out, I need a way to clear the offscreen tiles without erasing the textures. I have tried a couple more things this evening, the last one being writing to an array all of the tiles I want drawn to the screen and changing them as I scroll. This did not seem to work.

It would be greatly appreciated if anyone could shine a light on this for me.crowtongue2012-12-04 07:59:18
B
7
S
2
Posts: 123
Reputation: 1,061

Post » Mon Dec 10, 2012 7:01 am

Well... I guess I'm a little further with this, but still need help.

If I add a "Tile('tex') Equal to 0" condition into each of the events above then the texture will come back when you scroll the screen over and back.

The problem with this is that it loses one tile for copying as you scroll, so there will be tiles missing from the map for each one you place.

I've tried to set up another event to catch this and spawn another object in its place but this either loops and freezes construct or doesn't do anything.
B
7
S
2
Posts: 123
Reputation: 1,061

Post » Tue Dec 11, 2012 4:06 am

Is there any way where I can present my problem better or any crucial information I'm not passing along here?

I realize of all the people who are skilled at CC even fewer of them still browse these forums, So I definitely don't mean to be impatient... but it seems to be back to the drawing board unless someone can help me with this, and I've already spent quite a lot of time on it so I'd really prefer to not have to do that.
B
7
S
2
Posts: 123
Reputation: 1,061

Post » Tue Dec 11, 2012 7:13 am

Can you re-post the cap file? You just posted a persist file in your first post.

The tile recycling should work fine with the texture setter. I think the only change needed would be to remove the "set frame" action with an event to pick a tex and set the tile's texture with texture setter.
B
79
S
24
G
54
Posts: 4,743
Reputation: 40,749

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest