Hello Guest

Author Topic: Paint to tile map layer at runtime.  (Read 5600 times)

Afro-Ninja

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 62
    • View Profile
Paint to tile map layer at runtime.
« on: June 27, 2014, 06:52:36 pm »
Hi, I just want to know if this is possible. If so I should be able to dig around and get it working myself.

Let's say I have one tilemap with two layers- foreground and background.
Example: http://i.imgur.com/w2OpbR3.jpg

I want to be able to paint blood spatters to the foreground tiles.
Since we can specify separate sorting numbers for the tilemap layers I assume each layer is batched together as one big sprite at runtime.
It would stand to reason that after detecting collision I could place a blood spatter graphic at the collision point and copy the pixels that overlap any non-transparent ones.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Paint to tile map layer at runtime.
« Reply #1 on: June 28, 2014, 12:45:06 pm »
This should be easy enough as long as your blood splatters are aligned to tiles.
You can access each layer inthe tilemap from code, and change anything you like there, something like this:
tilemap.SetTile(x, y, bloodLayerIndex, bloodSpriteId)

Afro-Ninja

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 62
    • View Profile
Re: Paint to tile map layer at runtime.
« Reply #2 on: June 28, 2014, 05:05:52 pm »
Ah, gotcha.

Just in case, is it also possible to access the raw bitmap data? I'm not sure if the tilemap layers are flattened into one big, actual bitmap. painting to the tiles could result in a uniform look, I was hoping to get more of a splatter/painted feel.

If not I can certainly make the tile method work by making several blood tiles and choosing the right one(s) based on contact position.
It looks like I can add the blood layer programatically (at runtime) so I don't have to go through and manually do this for each tile map. Is that correct?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Paint to tile map layer at runtime.
« Reply #3 on: June 28, 2014, 09:13:33 pm »
You can't paint into the tile bitmaps.
You should add the blood layer before running the game, the functions haven't been tested at runtime.