Crazyninjaguy 8 Posted December 27, 2011 (edited) Introduction This is a complete rewrite of my older 'Second Parallax Layer' script to make it more performance friendly, and bug free. If you set a new map up in the script to have two parallax layers, then it will take the filename of the first parallax and add "_layer2" to the end, so for example, if you set "BlueSky" as your parallax, the layer 2 filename would be "BlueSky_layer2". If you want to display a parallax the default way, just don't set it up in the script. Screenshots Script #=============================================================================== # * AEE - Second Parallax Layer # * By Crazyninjaguy # * http://www.planetdev.co.uk # * Part of Cng's Ace Engine Evolution # --------------------------------------------------------------------------- # * Follow the script instructions to setup correctly. #=============================================================================== $imported = {} if $imported == nil $imported["AEE-ParallaxingLayers"] = true module AEE module Parallax # Leave this line alone MAPS = [] # Set this to true if you want MAP[Map ID] to have two parallax layers. MAPS[1] = true # To add a new map to the script, simply add MAPS[Map ID] = true # on a new line. For example. # MAPS[12] = true # Without the '#' at the start of the line. end # Parallax end # AEE class Spriteset_Map include AEE::Parallax #============================================================================= # * Create_parallax - ALIASED #============================================================================= alias aee_spritesetmap_parallaxing_createparallax create_parallax def create_parallax aee_spritesetmap_parallaxing_createparallax @parallax2 = Plane.new(@viewport1) @parallax2.z = 201 # Above Character end # create_parallax #============================================================================= # * Dispose_parallax - ALIASED #============================================================================= alias aee_spritesetmap_parallaxing_disposeparallax dispose_parallax def dispose_parallax @parallax2.bitmap.dispose if @parallax2.bitmap @parallax2.dispose end # dispose_parallax #============================================================================= # * Update_parallax - OVERWRITTEN #============================================================================= def update_parallax if @parallax_name != $game_map.parallax_name @parallax_name = $game_map.parallax_name @parallax.bitmap.dispose if @parallax.bitmap @parallax.bitmap = Cache.parallax(@parallax_name) @parallax2.bitmap.dispose if @parallax2.bitmap if MAPS[$game_map.map_id] == true @parallax2.bitmap = Cache.parallax("#{@parallax_name}_layer2") end Graphics.frame_reset end if MAPS[$game_map.map_id] == true @parallax.ox = $game_map.display_x * 32 @parallax.oy = $game_map.display_y * 32 @parallax2.ox = $game_map.display_x * 32 @parallax2.oy = $game_map.display_y * 32 elsif @parallax.ox = $game_map.parallax_ox(@parallax.bitmap) @parallax.oy = $game_map.parallax_oy(@parallax.bitmap) end end # update_parallax end # Spriteset_Map Credits Please credit me if you use this. Not available for use in commercial games unless you contact me about it. Edited February 6, 2012 by Crazyninjaguy 2 Wren and ShinGamix reacted to this Share this post Link to post Share on other sites
BulletPlus 7 Posted December 27, 2011 really useful script. thank u. 1 duktsubi reacted to this Share this post Link to post Share on other sites
ShinGamix 101 Posted January 3, 2012 I just learned about parallaxing like this. you have great timing. Share this post Link to post Share on other sites
shaz 77 Posted January 3, 2012 Thanks for this - was thinking about doing something similar myself. I thought it might be nice for a script to look at the parallax used on the map, then look for another file of the same name, with a prefix or suffix, and just automatically use it if it exists - would save designer having to change the script to specify the second layer name. Would be a drawback though if you had 2 layers named appropriately and only wanted to use one of them for some reason. And thanks for making this available for commercial projects Share this post Link to post Share on other sites
Crazyninjaguy 8 Posted January 3, 2012 (edited) Hmm, that could be a neat way around it yeah, also it could seem a little more user friendly! Also, edited with a quick bugfix. Edited January 3, 2012 by Crazyninjaguy Share this post Link to post Share on other sites
Lear 0 Posted January 4, 2012 I get an error "Script 'Second Parallax Layer' line 47: NoMethodError occurred. undefined method `bitmap' for nil:NilClass Share this post Link to post Share on other sites
achille 1 Posted February 5, 2012 For those who recive that error message, just repleace in Spriteset_Map at line 54 : def create_parallax @parallax = Plane.new(@viewport1) @parallax.z = -100 end++ With : def create_parallax @parallax = Plane.new(@viewport1) @parallax.z = -100 @parallax2 = Plane.new(@viewport1) @parallax2.z = 201 end Share this post Link to post Share on other sites
Crazyninjaguy 8 Posted February 6, 2012 Apologies for the delay, I've been really busy with, well, everything. I've completely re-written this to be better, and hopefully bug-free, enjoy! Updated the first post with new information. Share this post Link to post Share on other sites
Pikalyze 4 Posted February 3, 2013 Very handy script :3. Share this post Link to post Share on other sites