Layer Graphics

Layer Graphics

FEATURES
Create image layers for maps that can scroll, move like the parallax or be stuck to the map. Created to be used for overlay mapping, fog or other image effects.

There are other scripts available that do a similar thing, this is just my implementation of it. I recommend trying the others out (as they are possibly better!). I created this for myself but thought I’d add it to my archive for anyone to use if so desired.

DOWNLOAD:
Get it here >

85 thoughts on “Layer Graphics

  1. GCBD says:

    EXCELLENT ! I love your work … My game is only composed with your scripts, haha !

  2. TM5 says:

    How would I get the graphics to display over the charactor. like walking under trees,bridges, or behind buildings?

  3. TM5 says:

    KACHING!!! Never tried a Z value above 20. Entering 100 still had my charactor passing over the pic… But when I entered 200 my charactor passed under it! Thank you for the clarity on the numeric ranges… Awesome.

  4. Yin says:

    With this can I create layers above and below players (like the star tile)?

    • Galv says:

      You can place graphics above and below players with this, yes.

      • Yin says:

        What z value should I use for that?

      • Yin says:

        Wait, I think we misunderstood each other. When I say above and below, I mean at the same time. Say I have a character that’s over 32 pixels and a dresser that is also tall (over 32 pixels). From the bottom, the character would be below the dresser, but from above, the dresser would be above the player.

  5. Galv says:

    Ahh, sorry no it doesn’t do that. Each layer can only be in one position.

    Sounds like you could use an event graphic for what you want to do

    • Yin says:

      Thanks, I’ll still use it anyway because it’s easy to use and does everything else I need it to. I’ll use and event for the above problem. BTW do you have any way to make it work with MGC’s Map Zoom? Or is that something too complicated?

      • Galv says:

        I haven’t seen that script, not sure how hard it’d be to make it compatible but I don’t have time to look into it at the moment I’m afraid

  6. Yin says:

    It’s no problem, thanks for this script, it is very useful.

  7. Yin says:

    Hello again Galv, I have a couple of other questions. I have a mountain that is above the hero, but I want some events to be on top of it. How do I make my Above All events show up above the layers. Also, is there a way to just update one layer instead of all of them. I am on one map and I have a scrolling background that I don’t want to stop scrolling as I walk down the hill to trigger a different image on the same map. When I use refresh layers it reloads all of it and I can see my scrolling image get reset too.

    • Galv says:

      Hmm, maybe create the layers you want prior to loading the map so you don’t need to refresh them. Make the ones you don’t want to appear opacity 0 and change the opacity to whatever you need (then you don’t need to refresh layers as it already exists).

      Try making z value 200 for appearing above ‘same as character’ and and below ‘above character’.

      • Yin says:

        Ooooooh Ok lol. Wonder why I didn’t think of that myself. I’ll try different z values I just kept the default from the demo which is around 500 or so. 1 more question: is there any way to pre load all maps through a script call from a preconfigured set? The way I have it now it’s set by a common event, but if I need to change all of them (they are all set to 500+ for above :() I need to go through each script call and change it, if it was in a file, I could just search and replace.

  8. Galv says:

    I’m not exactly sure what you mean, but you could set it up so all the script calls to create layers were a method in your script list or something and change them all there.

  9. Chameleon1333 says:

    Great script first of all. I’m looking to set layers below the map (probably a few). I want to create the look of depth by having each layer down scroll with the character movement at a smaller and smaller rate (higher rate for items up in the sky, like a floating island). In the script i can see it is set to y32 x32 so scrolls at same rate at map with movement. if i change the lines
    self.ox = 0 + $game_map.display_x * 32 + @movedx + xoffset
    self.oy = 0 + $game_map.display_y * 32 + @movedy + yoffset
    to something else i get this effect, but this would only work if i was only using one layer in one place. Is there a script call i can use to set the rate for each layer or is the some can be added to this script to allow this?

  10. Galv says:

    If you mean what I think you mean, you can do that already in the script by changing the x_offset and y_offset numbers in the script calls when making the layer :)

    • Chameleon1333 says:

      oh jeez. can’t believe i didn’t try that. i must have been up to late last night. i think i was thinking that was for something else. Other scripts i have looked at have used the x,y offset verbiage to mean placement on the screen, to offset it that many tiles from it’s original location (like using position:relative; in css code for websites). Using the offsets i noticed that the layer wasn’t moving correctly when i was going u and down. looking in the script i found this (line 309):
      def yoffset
      $game_map.display_x* @layers[@id][7]
      end

      looked like it was trying to define the yoffset using the x axis, so i changed the display_x the a display_y. and that fixed it.

  11. devilarms2099 says:

    Hey Galv,

    I got a quick question. I plugged this in, with just a layers folder and I’m getting an error on line 268

    Script ‘ Galv – Overlay’ line 268: Syntax Error occured.
    unexpected tIDENTIFIER, expecting keyword_end
    @name = @layers[id] [0] #filename

    I looked through your demo and I’m at a loss after I added all the graphics from the demo to mine i’m getting the same error

    • Galv says:

      Sounds like a problem random people keep having when copying script code from this blog. I can’t replicate it, works fine for me but apparently some people’s browsers copy other symbols in the code.
      I’ll try to upload a demo today with the latest version so you can copy it from there and see if it works

  12. devilarms2099 says:

    Sounds good! I’ll try it once it’s uploaded :D

  13. Aeronx says:

    Hello Galv! Thanks for you work! But i have a problem, im using SAS, and if i add more than 2 layers, it starts to lag! Any way to solve this? thanks in advance

  14. Chameleon1333 says:

    i just started using the “Unlimited Res” script from Tsukihime http://himeworks.wordpress.com/2013/10/25/unlimited-resolution/

    i’m having the resolution set to 1024×768. This causes issues with a lot of script that are expecting the default resolution. In almost all cases i’ve been able to go in and adjust the script for the new res, but not for this one though. starting from 1×1 if you walk down or right to a certain point you cross an invisible line where the overlay doubles itself at an offset of each other. walking back causes it to disappear again.

    • Galv says:

      This script uses default planes that are a part of rpgmaker coding and the layers will repeat indefinitely.
      I don’t know what you mean is happening with the script but after a quick test they do not appear compatible. Perhaps ask Tsukihime as that is the script changing the defaults.

  15. Mrcgh says:

    I have a common event that create weather effect and the layer part is used in fog/cloud. Is a number reserved for current map or something? Or is it possible to use a variable for the map ID? I probably could work around and put the layer on all map if I ever need other layer it would become problematic pretty fast.

    • Galv says:

      Hmm, didn’t really think of using this for layers on a global scale. Ideally I would write something that controls global layers but I don’t have time right now unfortunately

      • Mrcgh says:

        Well, i don’t know much about ruby right now but can’t we just change the definition of the first value (the one referring the map_id) by referencing a variable instead? (I am clear? or stupid?)

      • Galv says:

        I haven’t looked because as I said, I am sorry I don’t have time :X

  16. Hi galv. I need your help i dont know why but im keep getting that error message: Script ‘Galv’s Layer Graphics’ line 82: NoMethodError occurred. undefined method ‘-@’ for true:TrueClass

    • Galv says:

      You need to provide a lot more info for me to help :/

      1. Check this list for things you might have done wrong:

      Errors Using VX/VX Ace Scripts

      2. Make sure your script calls are correct. My guess would be one isn’t.

      • Hmm i dont know what was wrong but after i removed scrip and added it again everything seems to work fine now.
        Galv did you tryed your script with Modern Algebras Animated parallax ? Will it work together ? If not is there any other way to make animated things such as fire, water etc in a way like you do it in rpg maker but by parallaxing method ?

      • Galv says:

        I haven’t tested my script with his, no, but I don’t see a reason they wouldn’t be compatible.

  17. Downwinds says:

    Hey there. This looks really good, but when I implement it and try to run my game, I get an error:

    ‘line 296: SyntaxError occured
    unknown regexp options – pa’

    I don’t know if it’s something I’ve done wrong. It’s currently the only script I have running (was just testing it in a blank project for now).
    I’ve got a script call ‘layer(3,1,[“Home_Upstairs”,0,0,255,0,0,0,0])
    layer(3,2,[“Home_Upstairs_Above”,0,0,255,100,0,0,0])’ set to autorun.

  18. Yin says:

    Hey Galv, when switching layers on and off it offsets by 1 pixel. Is there any way to fix this? I checked my images, they are all the correct sizes.

    Before switch: http://puu.sh/8tUyP.png
    After switch: http://puu.sh/8tUAu.png

    You can see in the corners there is darkness and a light that doesn’t quite line up with everything else. That’s from the in editor parallax showing underneath and it moves at a different pace from the map. You can also notice that the pillars are off by 1 pixel too. The ground layer is shifted to the left.

    My code: layer(75,3,[“Map75-Ground-2”,0,0,255,0,0,0,0])
    layer(75,0,[“Map75-Ground-1”,0,0,0,0,0,0,0])

    But it happens on other maps too.

    • Yin says:

      If I leave the map and come back, everything is in the right place.

    • Galv says:

      Hmmm, can you test this is a fresh project to see if it still happens? I cannot replicate it.

      Are you turning on and off the layers or changing the opacity of the layer? (Changing opacity instead might help?)

      • Yin says:

        I am just changing the opacity, doing it like you described in one of the other comments above. I’ll try in a new project and see if it might be an issue with compatibility.

      • Galv says:

        I didn’t test the opacity thing, unsure why it would offset it but I’ll do some tests when I have time.

  19. Yin says:

    Tested in your latest demo and the same glitch happens:

    • Galv says:

      Okay thanks – will look into that to try to work out what’s up when I can

      • Yin says:

        I fixed it by setting @movedx and y to 0 in init_settings.

        @movedx = 0 # @layers[0][@id][0].to_f # stored x
        @movedy = 0 # @layers[0][@id][1].to_f # stored y

        Don’t know if that breaks anything in the long run, but scrolling backgrounds work as well as the changing layer opacity and it doesn’t give me that 1 pixel x and y offset.
        Printing
        @layers[0][@id][0].to_f
        @layers[0][@id][1].to_f
        still gives me 1.0 for my last layer’s x and y, and 0.0 for other layers. Maybe it’s how that is done, but that is beyond my knowledge. Either way, it’s fixed :)

      • Galv says:

        Cool, glad to hear it. I still haven’t looked but will be when doing this for my own project

  20. Yin says:

    Is there an easy or hard way to animate layers through your script?

    • Galv says:

      Wasn’t designed for frame by frame animation if that’s what you mean. But if I were to do that I would use parallel process on the map of where it’s needed

  21. yougetagoldstar says:

    Is it just me or am I missing info on where to place the image layer you’re going to use for this script? Do you have to make a new folder? Script looks great btw, even discovering it years later.

    • yougetagoldstar says:

      Edit: Wait, nevermind. Looked at each line in the script and found out.

    • yougetagoldstar says:

      Yikes, for the 3 replies, if I could edit I would. So I got this thing working, great job. So my game starts in a house. I attached the layer script call to the door leading outside, but whenever I go outside theres a half second lag where I’m assuming the layer (one layer) is being loaded. Is that supposed to happen? The half second pause is not insanely noticeable, but if youre quick you notice.

      • Galv says:

        If you are using larger graphics then yeah, there will be a lag. Slower computers will lag even more. Something to keep in mind when using it

  22. yougetagoldstar says:

    Okay thx for still responding to your site, I respect that. Came up with another question some time yesterday. So my game starts in a house, and I have the layer script call set on the door that exits the house (this actually removed the lag I mentioned before–or either made it not noticeable whatever). When the layers load on the map, are they there forever? And if I enter the house and exit again, reactivating the script call will that do something like load another layer on top of the layer I just made, like loading more data on top of more data? Or does it not “stack up” like that? Sry if I can’t explain this perfectly, hopefully what I said made sense. Should I set a switch so that once the layer loads I should deactivate the script call or something?

    • Galv says:

      Ohhh I think I see what you mean by the lag.

      Yeah once you specify a map’s layers they stay forever (unless you change them again). You can create them all before you go to the actual map and then you won’t have the use the layer refresh (which does cause lag if you do it mid-map)

      I have mine set up to specify layers for all my maps at the start of the game

      • yougetagoldstar says:

        Awesome man, good idea about loading maps at the start of the game. This’ll probably be the last thing I notice for a while, but when I open the character menu on a map that has my layer, and close it, it takes a little bit longer to close. Have you encountered that before? I think my maps are a bit large so that might be it, but just incase I’m doing something wrong I figured I’d ask. Thanks again.

      • Galv says:

        Yeah that’s the original lag I thought you were talking about. Unfortunately large graphics take a long time to load in rpgmaker for slower processors.

        I have written a script for my own personal project that keeps the current map graphic in cache even when opening the menu so it doesn’t have to reload them when closing the menu again.
        I don’t know when I will have time to release it, though – super busy at the moment. Remind me after Christmas hehe

  23. yougetagoldstar says:

    I have yet to reach the part in my game where I have to learn how to script so even hearing the word “cache” makes ur plans sound hardcore. No worries man, have a happy christmas.

  24. Yin says:

    Hi again Galv. I’m wondering if there’s a way to check the status of a layer through a script call. For example, if layer 2’s opacity is equal to x then do something, else do something else.

  25. Kyra Usagi says:

    Just one tiny quest. I have the scirpt set up and the fog works great but for some reason it will only turn on when i go into my menu (items ect…. ya know) do you know why that is?

    • Galv says:

      The fog only loads when you go to a new map or in/out of menu or if you use the script call to refresh the layers. I recommend setting up the fog on an initial map for all other maps then you don’t have to use the loading script call

  26. Kyra Usagi says:

    Thank you the refresh layers works perfectly!

  27. logan7007 says:

    I hope this one goes to MV. This script is a lifesaver!

  28. Ushi says:

    Hey there, Galv. Can i put picture under animation layer?

  29. Lucas says:

    Well not sure If my comment went through. I didn’t see it. But anyways I need some help with drawing a parallax layer.

    I need something that works just like the normal parallaxes in VX ACE. I need something that stays relative to the screen, but that is also behind everything. The reason is Woratana’s Fog script breaks the parallaxes, and I want to use this to replace them.

    • Galv says:

      I don’t know exactly what you mean but it sounds like this plugin can do what you want. Read the instructions and see the demo for examples of layer settings.

      • Lucas says:

        I’m very familiar with your script, I’ve already used it for many other layers in my game. But for the life of me I can’t seem to get something to follow the screen like a normal parallax. Is there a way to set the parameters of the script call to make them follow the screen?

      • Galv says:

        What do you mean follow the screen? Like a “Show Picture” is stuck to the screen and is in the same screen position no matter where the player is on the map?

        If so, make the xShift and yShift both -48 (that’s negative 48 assuming you use default tile size of 48 pixels)

      • Lucas says:

        Yeah that’s exactly what I mean. I tried it out it works! I put in -32 for both and it worked. I knew there was an easy solution to it! I see now how your offset code works! I was trying to figure out that perfect number.. lol. Thanks man you’re the best! :D

  30. Ally says:

    I galv, I have a problem…
    I add a layer graphic in PS, like this:

    (I not use the parallax map, the map is created directly in RPG Maker)

    What happens is this.
    The library should have the picture above, but instead not appears:

    In other points of the map instead the picture is displayed:
    In PS:

    In game:

    Thank you for your reply ^^

    • Galv says:

      Unfortunately showing these screenshots of what you are doing isn’t helping as I don’t know what you are doing at all or what the pictures you are showing me are meant to look like.

      I recommend studying the demo and spending more time trying to work out what’s happening.

      • Guiguimu says:

        He is trying to show the layer above the bookcase, and in those shoots it appears on the ground but doesn’t appear on the bookcase.

      • Galv says:

        Oh I see. You’ll need to increase the z value of the layer to raise the layer graphic up

  31. Ally says:

    Thanks for your reply Galv…
    I have carried out some tests, and does not work if the number ground tag is greater than 0…

    it is possible to provide for a fix?

  32. Hey there Galv, how are you doing mate? This script is awesome and really easy to use! But i’m having some troubles with khas awersome light. In his script i set the z value of the lights to 6, and an overlay picture z to 200, but the lights still appear above the overlay, is there a way to fix this ? Thanks and keep up the good work!

  33. Giga Otomia says:

    I was wondering if there was a way to get a layer to scroll half as fast as the rest of the map?

Leave a comment