[SOLVED] Color Collision

Solved using a work around. Thanks @Bubble and @Keith_1357!

Hey Everyone!

I’m wanting to make a game that involves color collision. Usually, I would just make a variable for each object saying what color it is, but that doesn’t work for objects that are multiple colors (such as a square that is half purple and half yellow).

Is there any way to check if 2 objects collide with the same color?

Thanks in advance!
– Snowy

1 Like

Hi,

If I get you right you want to know the color at the location of collision and the colliding objects can have two or maybe more colors. In that case you could probably use the ‘Read pixels’-extension.

2 Likes

My method would be to make the animation with the color names and then compare the 2 animation names. There are infinite ways to do it.

You can’t really just compare the colors though because there’s always a chance that a word could be within another word or combined words. Meaning the word grape contains ape. So, you couldn’t just check if the word grape contains ape. My approach is to add a character like an asterisk before and after a word so it’s comparing ape to grape or red to redbluegreen

Then you could convert 1 animation name to an array with array tools and check if any of the items in that array are in the other animations name.

To split the animation name into array you could name the animations with the colors seperated by commas and then split the string into an array.

Or you could use a seperate array that contains all of the possible colors and then check if the animation contains each color and check if 2 objects are picked.

I don’t have time for any example events but someone else might be able to either expand on my concept or share one of their own techniques.

2 Likes

Save the colours into an array variable and then on collision walk through the arrays for each object to see if anything matches.

x1 vs y1
x1 vs y2
x2 vs y1
x2 vs y2

1 Like

Thanks everyone for your help. I think I was a bit misunderstood which is a problem on my end :laughing:

I want to have one sprite with 2-4 different colors, and run an event based on what color the player is touching.

Anyone know if this would be possible?

No solutions here, but is this pic what you want? You want to know which part of the target object the player sprite (not the player’s cursor) is in collision with and then get its color?

3 Likes


Yep.

For more context, I am considering trying to remake “Color Switch” where you bounce a ball through these multi-colour circles, and if the ball touches a part that isn’t the same color as the ball, you lose.

1 Like

Couldn’t you make four arc objects with different colors and check which one the ball is in collision with? You would just place the arcs to form a ring.

2 Likes

True, but they have to spin. I guess that could work though, as there is someone else already asking about rotating around a single point.

1 Like

Nope, just change the center point of the arcs to be where it would be when they’re part of a circle. Then pop them in a group and rotate the group.

Arcs drawn roughly in Piskel

Spinnig arcs

4 Likes

Could I by chance get the events for the rotating arcs? :laughing:
Guess it’s a little easier than I thought!

Yeah, that sounds much easier. Although, I still want to try the mechanics of what I originally thought was the concept.

So, yes, you could use different animations for each segment and check whether the colliding ring segment and ball animations are not equal to each other.

2 Likes

I didn’t do anything special. For the purposes of the gif, I didn’t have any conditions:
Rotate Arcs Group at speed x deg/second




And for extra clarity, here’s an example of one arc and its center point.

3 Likes

Thanks so much bubble!

One other thing, when it spins around, there is a small gap that appears between each arc. Any idea how to fix that?

Thats most likely (im guessing) happening because they dont match in size, try messing about with each one, each sprite is duplicated correct so they have the same size?

1 Like

Yep. They all have the same size.

Also, just found a fix. Thanks everyone for your help! :smile:

2 Likes