best way to make a static HUD and other overlays?

For questions about using Classic.

Post » Sun Feb 03, 2008 7:52 am

I'm in the process of setting up a static HUD panel, along with some collision boxes to prevent a few things from going wrong when 2 players are moving on screen.

Now, thanks to deadeye's suggestions, I have an object that controls the scrolling.

It moves up the background map, and is set to "centre view on me" , while the player objects can move freely over the background.

now when it came to setting static objects on the screen i was doing :

always set Y to scrollcontrollersprite + 144
always set X to scrollcontroller X pos

that way the objects are always sat in the same place.

the problem lies in the fact that when the player moves on the X axis, the background controller moves in the opposite direction, 1 pixel per tick.

when this happens the HUD objects shift by 1 pixel left and right, making the HUD wobble every tme the player moves on the X axis..

Deadeye tells me I can use a second layer and set the scroll movement to zero, but the overlaid layer doesnt display anything on it when I run the app..

the collision objects seem to be there, but they cant be seen, and bsides it seems like they are locked to the scrolling backround after a bind of blind testing..

can anyone help?

Thanks
B
4
S
2
G
5
Posts: 149
Reputation: 2,025

Post » Sun Feb 03, 2008 11:20 am

[quote="work3":ckc6f3m1]

Deadeye tells me I can use a second layer and set the scroll movement to zero, but the overlaid layer doesnt display anything on it when I run the app..

the collision objects seem to be there, but they cant be seen, and bsides it seems like they are locked to the scrolling backround after a bind of blind testing..[/quote:ckc6f3m1]

Hmm, don't know what to tell you about that one. Sounds like a bug, maybe? Here's a .cap showing that this method does work, though:

http://www.mediafire.com/?aejdnznk0cx

Setting different scroll rates on layers is how you do parallax scrolling, so setting the HUD layer to 0% scroll rate for x and y should do the trick (as it does in the example .cap).
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Sun Feb 03, 2008 5:05 pm

deadeye is right, the best method for a static HUD is a layer with 0% scroll X/Y rates. Remember to put your HUD stuff in the top-left area of the layout to get it to display, because that layer will remain always scrolled to 0,0.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Sun Feb 03, 2008 8:12 pm

Hey work, maybe you could post your .cap so we could see what's going on with it? Unless it's top-secret of course ;)
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Sun Feb 03, 2008 10:43 pm

hmm - it seems that i'll try and shift it all to the top left and see what happens, sounds like that could be it..
B
4
S
2
G
5
Posts: 149
Reputation: 2,025

Post » Mon Feb 04, 2008 5:06 am

*edit*

yep, that works perfectly - the reason why it was disappearing ws that I hadn't the objects at the very top of my playfield..

BUT - I was also using the layer for some invisible boundaries - it seems that one layers' objects can't collide with other layers objects.. is this true?
B
4
S
2
G
5
Posts: 149
Reputation: 2,025

Post » Mon Feb 04, 2008 5:32 am

i'm not too sure but i know that even though layers can be locked the objects can still be interacted with (i don't mean at runtime)
B
2
S
2
G
5
Posts: 293
Reputation: 2,236

Post » Mon Feb 04, 2008 10:17 am

so can different layers collide with each other? if so, how..

thanks, as always..
B
4
S
2
G
5
Posts: 149
Reputation: 2,025

Post » Mon Feb 04, 2008 11:13 am

Solid objects on different layers should collide by default, but for best results the two layers should have the same scrolling rate. If you have different scrolling coefficients on the different layers (like a hud layer set to 0,0 scrolling) then you'll get some funky results. It doesn't seem quite perfected yet. Parallax is best suited for display stuff only though, really. I can't think of a reason why you'd need things on different layers with a different scroll rates to collide.

If you want non-solid objects on different layers not to trigger overlaps, add an "obj1 is on layer obj2.layer" condition to the collision event.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Mon Feb 04, 2008 8:01 pm

[quote="deadeye":3l6czf52]I can't think of a reason why you'd need things on different layers with a different scroll rates to collide[/quote:3l6czf52]

I assumed this would be the best solution as aligning some collision boxes near the edge screen would be less hassle than checking for positional coordinates of moving player objects as the XY coords are always changing on a scrolling background.

as I mentioned I tried setting the collision bounds relative to the the object that centres the view, but the objects that were set relative to it were not 100% perfectly static
B
4
S
2
G
5
Posts: 149
Reputation: 2,025

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 6 guests