Spawn a tile

0 favourites
  • 7 posts
From the Asset Store
Piano tiles
$9.99 USD
Template for a piano tiles game, fully documented in comments and video
  • 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?

  • 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!)

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

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

    .

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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;

  • [attachment=2:1g4tdgr3][/attachment:1g4tdgr3]

    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.

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

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