[Solved]Remembering picked textures

This forum is currently in read-only mode.
0 favourites
  • 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:

    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 scirra.com/forum/plugin-texture-setter_topic43143.html.

    Here is an example:

    http://dl.dropbox.com/u/5426011/examples15/tiles_TextureSetter.zip

    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.cap

  • 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.

  • 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.

  • Bump

    Still not any further with this

  • 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

  • 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.

  • Ok so...

    If I were to get rid of Event #5

    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

    and my events for scrolling the map...

    +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

    then add in the event that r0johound suggested above...

    + System: For each tex

    + tile: Value 'tex' Equal to tex ('id')

    -> TextureSetter: Give tile the texture from tex

    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.

  • 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.

  • 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.

  • 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.

  • That's what I thought too. Maybe I'm just making it all too complicated again and missing the obvious. Hope you can prove me wrong

    I've fixed the link in my initial post. Also put in a different file and stripped down most of the unnecessary events.

    I removed the event that had the "set frame" action in it altogether as well. Thanks for looking!

  • Unfortunately I don't seem to be able to get any tiles to load, so I can't test why the textures reset.

  • I'm actually not sure if I need to share all of the images I've used or if they are embedded in my project. In either case here are two sets of images:

    https://dl.dropbox.com/u/69407974/app-images.zip

    https://dl.dropbox.com/u/69407974/images.zip

    App images are just images for my buttons and spritefonts. The images .zip contains a bunch of .png files.

    At runtime if you click the folder with a plus sign on it it should pop up a folder dialog. Select whichever folder you extracted the images.zip archive to and it should populate with tiles.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I have tried again a few times to put in a simple event replacing the one that changes the tiles animation frame. No luck.

  • Sorry for the late reply, I had a look and couldn't identify the issue.

    It may be something simple but it's time consuming to debug. If it helps give me a day or so and I'll try to make a example cap that combines the tile recycling and tiledbg texture bank.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)