Load new TILESET into a tilemap object, how?.

Discussion and feedback on Construct 2

Post » Sat Mar 25, 2017 10:29 pm

Hello, I have a tilemap object with its set of tiles.

I would like to know if I can load a new set of tiles on that object and how should I do it ?.

I do not want two different tilemap objects, I want to use the same object and for that I need to change their tiles according to the level the player plays.

-----------------------------------

In another case, why can not I access the width and height of the TILESET loaded in the tilemap object?
Last edited by The Mnk on Sun Mar 26, 2017 11:44 am, edited 3 times in total.
B
29
S
12
G
21
Posts: 782
Reputation: 14,411

Post » Sun Mar 26, 2017 3:03 am

When you create an object, any actions below that refer to that object, so maybe if you do something like:

Start of layout ->
create object Tilemap
load tilemap
create another object tilemap
load second tilemap

It should work. If you want better control over it you can just pick which tilemap you mean using IIDs. Something like:

Start of level->
Pick tilemap where tilemap.IID = 0 ->
Load tilemap1
Pick tilemap where tilemap.IID = 1 ->
Load tilemap2
B
123
S
43
G
41
Posts: 846
Reputation: 28,204

Post » Sun Mar 26, 2017 9:15 am

andreyin wrote:When you create an object, any actions below that refer to that object, so maybe if you do something like:

Start of layout ->
create object Tilemap
load tilemap
create another object tilemap
load second tilemap

It should work. If you want better control over it you can just pick which tilemap you mean using IIDs. Something like:

Start of level->
Pick tilemap where tilemap.IID = 0 ->
Load tilemap1
Pick tilemap where tilemap.IID = 1 ->
Load tilemap2


I'm not sure I understand this, I just want to load a new TILESET (NOT TILEMAP) into a tilemap object.

Then I do not understand ... what would help me what you say ?.
B
29
S
12
G
21
Posts: 782
Reputation: 14,411

Post » Sun Mar 26, 2017 12:03 pm

You can load an image from url into the tilemap, but you can't have 2 instances of the same object with a different image, so 1 image per tilemap object.
Image
B
74
S
28
G
12
Posts: 515
Reputation: 12,359

Post » Sun Mar 26, 2017 12:41 pm

Lof wrote:You can load an image from url into the tilemap, but you can't have 2 instances of the same object with a different image, so 1 image per tilemap object.


I understand but I think there is a bit of confusion, in DOC says this:

Load image from URL
Load a new tilemap image from a given URL. It is not used until the image has finished downloading, and On image URL loaded triggers. Images loaded from different domains are subject to the same cross-domain restrictions as AJAX requests - for more information see the section on cross-domain in the AJAX object. Data URIs can also be passed as an image, e.g. from a canvas snapshot or webcam image.


In DOC talks about loading a TILEMAP image, but does not say anything about TILESET, the TILESET is the set of tiles that you will use to build the map with the tilemap object.
I want to load a new TILESET in my TILEMAP object.
I understand that you can not have two equal objects with different TILESETS.
That's not a problem for me because I'm just going to have a single tilemap object.

I want to change the TILESET of my tilemap object at runtime.
But there is no action that is "Load new tileset" on the tilemap object.

Load image from URL I think it only loads a new map for your tilemap object, but it does not load a new TILESET for the object.

Maybe I'm wrong but I think it's not possible to load a new TILESET into a tilemap object, in fact, you can not access the properties (width and height) of the TILESET image loaded in a tilemap object.

Image
B
29
S
12
G
21
Posts: 782
Reputation: 14,411

Post » Sun Mar 26, 2017 12:50 pm

Oh, you can just save it to json and then load from json.
Image
B
74
S
28
G
12
Posts: 515
Reputation: 12,359

Post » Sun Mar 26, 2017 12:53 pm

Lof wrote:Oh, you can just save it to json and then load from json.


Yes, that is true but only the TILEMAP, you can not load a new TILESET in any way.
B
29
S
12
G
21
Posts: 782
Reputation: 14,411

Post » Sun Mar 26, 2017 3:28 pm

Edit: Sorry lol I just read your post from before and my assumptions were wrong.
B
123
S
43
G
41
Posts: 846
Reputation: 28,204

Post » Sun Mar 26, 2017 3:31 pm

andreyin wrote:I think I understand what you want, but you cannot do that.

You want 2 instances of the same tilemap object to have a complete set of different images in them, right?

That's impossible. The minute you change the tile images, all instances of that object will have the new images. Instances are just a copy of the object that are allowed to have different variable values, like height and such, but not images.


TILESET can not be changed.
Even if you only have one tilemap object.
It can not.
I only have one tilemap object, I do not need any more tilemap objects and I can not change their tileset.
B
29
S
12
G
21
Posts: 782
Reputation: 14,411

Post » Sun Mar 26, 2017 3:38 pm

What C2 is calling "a new tilemap image" is indeed a tileset.

Here's an example of how you load different tilesets:

https://www.dropbox.com/s/us4peovqb1btm ... .capx?dl=0

Each tileset is a separate image. You can check them in the Files folder in the Project Tree.

Edit: Keep in mind that changing the tile width/height in runtime is impossible, though.
B
123
S
43
G
41
Posts: 846
Reputation: 28,204

Next

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 9 guests