Parallax Scrolling

So I’ve been putting in more work on Parallax Scrolling this weekend and have made some promising progress.

There is one main issue currently which is, as always, physics. The main issue is having physics on layers that move at different speeds, i.e. parallax layers. If you have your physics objects on different layers that is fine but they have to move at the same speed so it is best to put them all on the “main” layer, i.e. the one your player, enemies and all other things are on. Which is probably the layer you would want them to be on anyway. You can still have them on ObjectLayers however they must also move at the same speed as the main layer.

With that limitation aside, on to the good stuff; how to get it working. It’s pretty simple really, just add a “ParallaxEnabled” property to the Map and set it to True.

Now for each layer you will want to set a speed factor which is how fast or slow the layer will move in relation to the others, you will probably want your main layer to move at the base speed of 1 so you can just leave it at that and then for layers that are closer to the camera you will want a higher value and then for layers that are further away you will want lower numbers. To set these values simply give the layer a property called “parallaxFactorX” for horizontal and “parallaxFactorY” for vertical. If you leave them out they will move at the base speed of 1.

The map needs a base layer to be able to clamp the camera to, you can either set this manually by adding the property “parallaxBaseLayer” to a layer or letting Lime work it out by picking the first layer, which will most likely be completely fine.

I will be uploading a sample to the Members area soon and also checking in a bunch of new code to the SVN for people that are that way inclined and after a few more people have tested the code in a real world setting outside of my sample project I think it will be time for full release of version 3.1.

[import]uid: 5833 topic_id: 8309 reply_id: 308309[/import]

Sounds good, looking forward to the next release as I certainly can see me using this to accelerate the dev process.

I’ve just started back using lime in the last week or so, I think I’m on version 2.9? from the members section, the speed is still a concern for me, I’ve been out of the loop somewhat as regards developments with lime and ansca/corona, but has there been any more movement from Carlos and co regarding performance improvements that you can let us in on? [import]uid: 11672 topic_id: 8309 reply_id: 29658[/import]

Carlos actually emailed me a few days ago just to say that they were currently focused on all these Android improvements they’ve been adding in which until recently weren’t working but after that was finished they would be focusing on performance and graphics so that is good news for Lime :slight_smile:

And glad you’re looking forward to the release, I will be uploading the sample soon for people to play with. [import]uid: 5833 topic_id: 8309 reply_id: 29661[/import]

Sounds promising [import]uid: 11672 topic_id: 8309 reply_id: 29664[/import]

Yea I’m still very confident that it will be fixed.

I have just uploaded the sample to the members area, just log in and go to the Downloads page. [import]uid: 5833 topic_id: 8309 reply_id: 29666[/import]

cheers
will try it out tomorrow, getting a bit late :wink: [import]uid: 11672 topic_id: 8309 reply_id: 29671[/import]

I was thinking that myself. Hope you enjoy it tomorrow and don’t find too many problems with it :slight_smile: [import]uid: 5833 topic_id: 8309 reply_id: 29672[/import]

Just purchased Lime, very excited to get started.

I downloaded the basic parallax example. I ran it on my ipad. What’s with the very visible seams around the tiles? They’re visible in the simulator and on the device.

[import]uid: 9035 topic_id: 8309 reply_id: 29763[/import]

I think that is to do with the content scaling up to the iPad size. For now if you wish to work on an iPad game you will probably have to use a map designed for the resolution, i.e. if you use the same 32 by 32 tiles then the map should be 32 * 24. [import]uid: 5833 topic_id: 8309 reply_id: 29798[/import]

Thanks for the advise, I’ll do some further testing. I did notice the artifacts on my 2nd gen iPod touch using the same demo. The artifacts only show up when scrolling the map back and forth.

BTW, do you know if there is a Tiled size limitation. When I create a 64x64 map in Tiled (with 32x32 tiles) and save it as an image it does not save as a 2048x2048 PNG. Rather it saves as a 1536x1536. [import]uid: 9035 topic_id: 8309 reply_id: 29807[/import]

The artifacts you see when you slide the map is actually an issue with the Transitions used to do that and can be visible on non parallax maps as well. I use to have the same issue with regular dragging so I needed to round off the position to get exact pixels, I am looking into ways of solving this with transitions.

I’m not sure of any size limitation but I guess there might be. [import]uid: 5833 topic_id: 8309 reply_id: 29811[/import]

The issue with the artifacts is now solved thanks to jmp909, for anyone that wants access to the fix you can either get it via SVN or I will simply email the function to anyone that wants it. [import]uid: 5833 topic_id: 8309 reply_id: 29900[/import]

I downloaded 3.1 and still have the artifacts on my iPad. I checked the repository but I’m not sure where to find the fix. [import]uid: 9035 topic_id: 8309 reply_id: 29916[/import]

The fix is in “lime-map.lua”, and more specifically the Map:slideToPosition() function, just copy that over your existing one and you should be good to go. [import]uid: 5833 topic_id: 8309 reply_id: 29975[/import]