best way to make a static HUD and other overlays?

For questions about using Classic.

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

Post » Mon Feb 04, 2008 10:00 pm

Okay, I'm a little confused so let's see if I've got this right... you want to keep something from going offscreen, but you still want scrolling? Correct me if I'm wrong.

The best way to do it would be to check an object's x,y coordinates with the visible edges of the window. It's a quick value compare, which is much more efficient code-wise than setting up collision boxes. Any time you are able to do something with just math, it's a good idea to just work it out. Checking the edge boundaries is quicker than calculating collisions, and having no collision boxes at the edges means less objects.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Mon Feb 04, 2008 10:28 pm

the screen edge bounds aren't right to the edge of the window, they're a fair bit smaller so that the moving sprite never goes off the screen.

they are also there to check where the second player is, so that if the window scrolls left, and the second player is on the far right of the screen, it will "push" the player on the far right to prevent him going offscreen.
B
4
S
2
G
5
Posts: 149
Reputation: 2,025

Post » Mon Feb 04, 2008 11:20 pm

Ah, I see.

Well, if you really want colliders at the edges of the screen then you would have to have them on a layer that matches the same x,y scroll rate as the layer your player sprites are on. This means that you will have to update your colliders x,y coordinates every cycle to match up with the scrolling screen. This can cause some buggy problems, though... if you manually set the x,y of a solid object like your screen barrier, then it's possible to move it into a position where it intersects with your player sprite. It would take a lot of tricky custom events to compensate for this.

If you're dead set on having barrier objects then you might do something like giving your barrier Bullet Movement. That way you can tell it to move towards where you need it on the screen rather than set it's x,y manually (it will still "push" solid objects rather than intersect with them). But even this method is getting rather complicated and convoluted for what you want to do.

The simplest, most efficient method would be to ditch the detectors altogether and use math. If you don't want your sprites to go half-way off the edge of the screen then make your edge collision condition look like this:

[code:2yo1b835]
sprite.X Less than (ScrollXRight-numOfPixels)
[/code:2yo1b835]

This will check whether your sprite is inside the visible play area as compared to the right edge of the screen, where numOfPixels is the amount of space you want to leave at the edge.

If you want to check if it's in the play area as compared to the top edge, you'd do like so:

[code:2yo1b835]
sprite.Y Greater than (ScrollYTop+numOfPixels)
[/code:2yo1b835]

You can check your second player's location just as easily using x,y value comparisons, so there's really no need for the barrier objects.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Tue Feb 05, 2008 12:22 am

Thanks redeye, it's alot to digest, but i'll experiment with it tonight - thanks so much as always
B
4
S
2
G
5
Posts: 149
Reputation: 2,025

Post » Tue Feb 05, 2008 1:08 am

Heh, sorry. Being long-winded is a bad habit of mine :P
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Previous

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest