Log In  

I've run into the same thing on a couple of projects, so I'm wondering if I'm missing something in regards to map().

  • sprites have flags marked 0-7
  • the map command has the optional argument 'layer' that will display only sprites of a certain flag
  • the default argument for layer is 0, which mean to show everything
  • if I mark a sprite with flag 0, then using 0 as the argument will just show everything (which isn't what I want)

I think in the past I just didn't make use of flag 0 and it looks like that's what Zep did with Jelpi, but it seems odd that I can't (I think) use flag 0 as a layer argument.

Thanks

P#95240 2021-07-24 15:55 ( Edited 2021-07-24 15:55)

The 'layer' argument doesn't take a flag number but rather a bit-field representing a set of flags.

In the sprite editor, if you mouse over one of the flag buttons you'll see that it displays the following:

  • flag 0 (0x1)
  • flag 1 (0x2)
  • flag 2 (0x4)
  • ...
  • flag 7 (0x80)

The numbers in brackets are in hexidecimal and each one is a power of 2: 1, 2, 4, ..., 128

With that you can construct a single integer which represents a set of flags. If you want flag 0 and flag 1 then that's 0x1 + 0x2 = 1 + 2 = 3.

If you want flag 5 and flag 7 that's 0x20 + 0x80 = 32 + 128 = 160, etc. Zero technically represents no flags. But if you specify no flags then map() just draws everything.

So for your question specifically, if you want to use flag 0 as a layer then pass 1 as the 'layer' argument instead of 0. But you can use the bit-field to include objects with different flags in the same 'layer' if you want to.

Hope that helps.

P#95243 2021-07-24 17:08

That's great!

Thanks!

P#95253 2021-07-24 23:53

[Please log in to post a comment]