Jump to content

Valid option for parallax scrolling


rtlehr
 Share

Recommended Posts

Hey all,

     OK, I don't program in Phaser much (I'd use it all the time if I could, but life gets in the way...), I pick it back up every now and then when I have the time, I'm also a self taught JS programmer, so I know how to make things work, but I don't know the deep details of doing things "the correct way" (for speed, resource space and such).  My son and I are creating a "Defender" like shoot-em up game and I created a background parallax image scroller for it.  There is an example below and a link to the code.

sample: http://www.rosslehr.com/demos/parallax/

Use the Left and Right arrows to move the ship. (on mobile you can use the joystick in the lower left)

code: https://github.com/rtlehr/parallax

     The scrolling of an image is based on the width of the image in relationship to a "benchmark" image.  The benchmark is the image that will be left justified at the beginning of the level and right justified when the ship is at the end of the level. 

     My question... Is this a valid (or "OK") way to do this? or is it a complete crazy way to approach it.  I'm looking more on the tech side of things (will this cause problems with the game that I am not even skilled enough to think about?), or have I complicated something that can be accomplished with just a couple lines of code

I know people are busy and appreciate any help/advice anyone can give.

Thanks,

Ross

Link to comment
Share on other sites

I really like the art style on the ship. :)

I don't quite understand your explanation. I think you're saying "the benchmark is the largest image and I parallax everything in a ratio to it". That's probably fine. I tend to err on the side of "if I have working code then the way I'm doing it is probably fine."

Two things: you're using a really ancient version of Phaser, 2.0.2. It's on version 2.5.0 now. And whoa whatever you're using for hosting is really slow!

Link to comment
Share on other sites

Thank for your note.  I follow the same advice, but Phaser get's into some things that I never tried, so I just want to make sure.  This project is just for fun, but I am learning a lot working on it.  The host isgodaddy, and I'm looking for a new service now.

It works with 2.5 also, I should switch it.

Actually, I can choose the image I want to be the benchmark, I can choose the largest one, but I can also choose and image that might be in the middle of the depth order of the images.

 

Thanks,

Ross

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...