How to use: slice contains?

Ask and answer questions about making games and related topics. Unrelated topics go in that other forum.

Moderators: marionline, SDHawk

Post Reply
User avatar
sheamkennedy
Liquid Metal Slime
Posts: 1110
Joined: Mon Sep 16, 2013 9:29 pm
Location: Tama-shi, Tokyo, Japan
Contact:

How to use: slice contains?

Post by sheamkennedy »

EDIT: I actually think the answer might be that I'm comparing my hitbox to see if it lies within the zone container which consists of many rectangle slices attached to zone 1. Since my script is checking if "f" is within "zone container" then perhaps the case is false because "f" isn't contained within every instance of the rectangle... This is just a thought though, I'm not sure.

I'm having trouble implementing the "slice contains" function and am wondering if I am not understanding it correctly.

I have the following script called within my autorun script:

Code: Select all

#  if (FindCollidingSlice (ZoneContainer,f)) then(
  if (slice contains (ZoneContainer,f)) then(
    # Fall Down Pit
    # Perform Death Dissolve
    ...
    game over
  )
Note: When I perform a collision check with "FindCollidingSlice (ZoneContainer,f)" the script works fine but I'd prefer to use "slice contains" as it seems more practical for what I'me trying to achieve.

In the game I have a pit. The pit is represented by a rectangular slice. When my hero's foot hitbox is completely contained within the pit slice I would like the player to fall into the pit resulting in a game over.
Last edited by sheamkennedy on Tue Oct 24, 2017 5:49 am, edited 2 times in total.
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
� C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Re: How to use: slice contains?

Post by TMC »

I'm confused. The following two statements seem contradictory:
I'm comparing my hitbox to see if it lies within the zone container which consists of many rectangle slices attached to zone 1.
In the game I have a pit. The pit is represented by a rectangular slice.
If you want to find whether one slice is entirely within a rectangular region, use "slice contains". Your code for that looks correct. Note that "slice contains" ignores all children of both slices, so they are just two rectangles.

"find colliding slice" tests for any amount of intersection, not just total containment. You were also using that command correctly.
Note that "find colliding slice" ignores the children of the slice you're checking against (f). Because it loops through lots of slices, it can be used for non-rectangular areas.

Are both f and ZoneContainer parented to map layers or the walkabout layer? The collision detection is done based on screen position, and it doesn't matter what they're parented to. But if one is parented to the default scriptlayer slice, then its position doesn't move with the camera, so its screen position might not be what you expect.
Last edited by TMC on Wed Oct 25, 2017 4:04 pm, edited 1 time in total.
User avatar
sheamkennedy
Liquid Metal Slime
Posts: 1110
Joined: Mon Sep 16, 2013 9:29 pm
Location: Tama-shi, Tokyo, Japan
Contact:

Post by sheamkennedy »

Ahh, I think what you said about parenting is the reason for the script not working. After parenting to the same map layer everything seems to work fine. Thank you!
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
� C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases
Post Reply