Spawn a tile

Just started using Construct 2? Post your questions here

Post » Thu Jan 22, 2015 11:19 am

I got 2 kinds of objects that change each other after collision with bullet. The problem is that i want to multiply these objects which is not wisely to do for a memory usage.
I know that we can replace a sprite with a tile and set a collision , but we cannot spawn a tile. So, how can we generate a tile instead of another tile? Is there a an alternative to "spawn an object" in this case?

Image
B
8
S
2
Posts: 48
Reputation: 646

Post » Thu Jan 22, 2015 6:13 pm

When you say tile, are you referring to the tilemap? In which case you don't spawn it but rather set the tile at x,y to be what you want (0-n)

also... you destroy the object before you have it spawn a new one. Is it still spawning the new one?

Also, instead of destroying the object and creating a different one, you can simply change animations, and set a flag for whether it is yellow or white. If it just comes down to changing the color of the sprite (or tile in a tilemap) I wouldn't destroy and create objects.

(be sure to use @ruskul if you respond or I won't see the post!)
Image
B
33
S
11
G
2
Posts: 563
Reputation: 5,141

Post » Thu Jan 22, 2015 11:18 pm

ruskul wrote:When you say tile, are you referring to the tilemap? In which case you don't spawn it but rather set the tile at x,y to be what you want (0-n)

also... you destroy the object before you have it spawn a new one. Is it still spawning the new one?

Also, instead of destroying the object and creating a different one, you can simply change animations, and set a flag for whether it is yellow or white. If it just comes down to changing the color of the sprite (or tile in a tilemap) I wouldn't destroy and create objects.

(be sure to use @ruskul if you respond or I won't see the post!)


After your comment, I switched to tilemap ( before I used tile background as a tile ). In short, I want to shoot with a yellow bullet at the white unsolid box to make it yellow solid box. If I shoot with white bullet at this yellow solid box, it will turn out again an unsolid white box.
So, I tried to set "set a position", but it seems that I badly understand its function. I thought that it should replace one object with another, but it did not work here.
Image
B
8
S
2
Posts: 48
Reputation: 646

Post » Thu Jan 22, 2015 11:44 pm

Okay, now I think I understand what you want.

the Tilemap plugin should have it's position left alone. Think of the actual tilemap as a grid where different tiles can be displayed. If you move the tilemap, then you move all the tiles in that map. You can turn tiles on or off by setting the tile at a specific location to be any tile within the tile map. you can get this number by looking at the number when you hover over it in the selection panel.

The problem with the tile map, is that does not support collisions being off unless it is an empty tile. But it looks like you want a tile to still be there even when it is not solid.

Instead of using the tile map, you could use something like this:




.
You do not have the required permissions to view the files attached to this post.
Image
B
33
S
11
G
2
Posts: 563
Reputation: 5,141

Post » Thu Jan 22, 2015 11:48 pm

Basically, you can change the variables to what you want, but essentially, I have 1 bullet and block

the bullet has a variable i called color and stores a string. The block has a Boolean variable, but you could even use the solid behavior as the flag instead (is solid enabled).

Basically, when a bullet hits a block we check to see if the block is the right color (on or off) to be changed by the bullet. If it needs changing we do so.

I use animation frames on the block to what color it is. Since a boolean = 1 or 0 (true and false) when I set an animation frame to the boolean, I am setting it to either be 1 or 0. Just remember if you use frames in the animation, you need to make sure you have the animation speed set to 0;
Image
B
33
S
11
G
2
Posts: 563
Reputation: 5,141

Post » Fri Jan 23, 2015 10:04 am

tile1.jpg
ruskul wrote:Basically, you can change the variables to what you want, but essentially, I have 1 bullet and block

the bullet has a variable i called color and stores a string. The block has a Boolean variable, but you could even use the solid behavior as the flag instead (is solid enabled).

Basically, when a bullet hits a block we check to see if the block is the right color (on or off) to be changed by the bullet. If it needs changing we do so.

I use animation frames on the block to what color it is. Since a boolean = 1 or 0 (true and false) when I set an animation frame to the boolean, I am setting it to either be 1 or 0. Just remember if you use frames in the animation, you need to make sure you have the animation speed set to 0;


1) Is block a sprite? If so, I am facing a problem with using hundreds of sprites in one layout.
2) It is not about just changing colors of one object, 2 bullets differ a little from each by texture(or shadows) , the same may go for boxes.
You do not have the required permissions to view the files attached to this post.
B
8
S
2
Posts: 48
Reputation: 646

Post » Sat Jan 24, 2015 12:01 am

Tile map would be better to use... though that brings up an really big problem. How do you know what tile in a tilemap has colided with the bullet. I think you have to run some complex case scenarios with basic trig involved. If you can get it working without the tilemap first, you would be in a good spot to tackle it using the tilemap. I just spent the last 15 minutes trying to use the tile map and there is no quick and easy solution unless I am missing something.

I asked a question here that if answered will solve the problem:

viewtopic.php?f=147&t=123332&p=877321#p877321
Image
B
33
S
11
G
2
Posts: 563
Reputation: 5,141


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 1 guest