Hey guys, here is a class I put together after reading an example of Parallax Backgrounds by Adnaan--all the actual code credit goes to him, but I have cleaned up the code a little and packaged it as a class with some extra options that others might find useful in their games. So I decided to share it as well. Enjoy
To use it you will need a simple table with the images to use like the following, after that it's a sprite you can do what you want with in the game:
-- Setup background images to use.
local bgs = {
bg1 = "bg1.png",
bg2 = "bg2.png"
}
-- Create a new Parallax background sprite with a speed of 5
local bg = ParaBG.new(bgs, 5)
-- Add background to scene--should be done before any
-- sprites/controls so it's behind everything.
stage:addChild(bg) |
For Adnaan's post:
http://giderosmobile.com/forum/discussion/387/parallax-background
Comments
Likes: unlying
Likes: Teranth
Likes: Teranth
http://giderosmobile.com/forum/discussion/387/parallax-background
Likes: GGGRRR123
https://play.google.com/store/apps/developer?id=My+name+is+Originality
changing the order at which things happens seems to fix it.
I mean, i'm using 2 different images as a scrolling background and when the first background's far X reaches 0 it automatically recreates the first background even when the 2nd background is still scrolling. I dunno it kinda feels like it's just teleporting?