Jump to content
Crazyninjaguy

AEE - Second Parallax Layer

Recommended Posts

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

 

r70s9t.png

 

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 by Crazyninjaguy

Share this post


Link to post
Share on other sites

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

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 by Crazyninjaguy

Share this post


Link to post
Share on other sites

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

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted