Parallax - sprites not moving

Started by Kinoko, Mon 10/10/2005 11:00:33

Previous topic - Next topic

Kinoko

Started using the Parallax plugin for the first time today. I think I have it set up fine, I have a normal scrolling room with 2 parallax "background" sprites drawn on top. The only problem is that as I move my character around on the room, the 2 sprites follow him exactly, ie. Don't move at all. I've tried changing the speed and the position of the sprites and it makes no difference. I have -no- idea what's not working...

For reference, I have this code in the room's "before player enters screen" script:

Code: ags

pxDrawSprite(0, 1, 1, 580, -100);
pxDrawSprite(1, 1, 1, 579, -50);  

Gilbert

[Plug]
For simple parallax layers that are drawn on top, did you try my parallax scrolling module? :=
[/Plug]

Kinoko

#2
I... didn't even know it existed so I'll give it a look, thanks.

EDIT: I just read yours can only use overlays and I need my parallaxing behind the characters/objects/whatnot.

Kinoko

Forgive me but I figured I'd give this another go with a *bump*

Gilbert

Yeah I had posted in that other thread about ideas. But I'm too lazy busy at the moment to do anything to it.

Kinoko

Hopefully Scorporius will come and save my day once again. Thanks for your help though Gil, it's always appreciated.

Kinoko

Sorry to bump this, but still hoping someone can help me out.

dxtr

How exactly are you planning to use this parallax scrolling? 

If you give some more details I can probably try to help as I stumbled on this same question while experimenting for a new game.

Cheers,

Andrea

Kinoko

I'm at work so I can't show any screenshots, but I'll do my best to describe this one scene.

Basically, there's a floor suspended in space. So, beneath the floor, you can see stars. To make them appear far away, I want two layers of stars moving at different speeds.

What I tried was having the bottom layer of stars as the actual room background. On top of that is a layer of stars, and then the floor as a layer above that. Obviously, the character and all objects are on top of -that-.

The thing is, I'd like to use the parallax in other parts of my game, making use of layers on top of my character/backgrounds etc. So, the plugin theoretically should be perfect for what I want. It's just not working... as such. Whether it's the plugin or my code, I don't know.

dxtr

Ok here's my quick & dirty solution:

http://www.theroboz.com/kinoko.zip - everything is in the room script

One problem I found using the room bg as the bottom layer is that then the object you use as the floor (topmost parallax layer) will actually move faster then your character intended speed so, when the scrolling stops, your char looks as if he's suddenly slowing down...

Instead I use the room bg as the topmost layer and fake the parallax using two objects and the bg walkbehind... depending on the layout and dimensions of your room, this could be ok also for you.

Anyway check the sample (tested with AGS 2.71 rc3) then let me know.

Kinoko

Oh, thanks so much! I'm going out right now so I dont have time to check it tonight but will give it a look whenever I wake up tomorrow ^_^

If I didn't mention it before, the reason I used the stars as the background was because I didn't know how to make part of the "floor" background transparent.

Kinoko

Okay, a few days late but I finally got time to test your code. It works really well! As you mentioned, the only problem is that 'jump' at start when the room loads.


What I'm thinking is that there should be a way to calculate, before the room loads, the position the objects need to be set at in relation to the x, y of the character. I'm just not sure how to do that.

SMF spam blocked by CleanTalk