Detecting actors which are next to one another... like Candy Crush/Bejeweled?
TomCoffee
Member, PRO Posts: 175
Hi...
I've been thinking about this for a while and haven't come up with a great method... Is there a way you can think of to have one actor know if there is another actor next to it? Or touching on a certain side?
I've looked at templates, poked around the forum and run Google searches galore... what am I missing? I think the key is the process would have to run (or the actor would have to sense it) without a user's touch being involved.
Any ideas?
I've been thinking about this for a while and haven't come up with a great method... Is there a way you can think of to have one actor know if there is another actor next to it? Or touching on a certain side?
I've looked at templates, poked around the forum and run Google searches galore... what am I missing? I think the key is the process would have to run (or the actor would have to sense it) without a user's touch being involved.
Any ideas?
Comments
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
Now, if table value is 1, it means it's a yellow actor, 2 is green ect (or what type an actor is, you choose what you want those values to equal)
On each actor have an Detector attribute, integer in which that number can be changed depending on what actor your looking for.
To find one next to the one you touched, (or an event or continuous you just get rid of the of touch is pressed)
When touch is pressed, (if your doing it)
Another rule added with "any of these happen then"
If self.detector is equal to Tablevalue(table1,self.row+1,self.col)
Or
Tablevalue(table1,self.row-1,self.col)
Or
Tablevalue(table1,self.row,self.col+1)
Or
Tablevalue(table1.self.row,self.col-1)
Then do event you want to happen.
Self.detector is used to get the value needed to check. If you want to know if a value 1 (could mean a yellow actor) is near change it to 1. It will then, when press check if there is one next to.
If you only want one direction, get rid of some of the tablevalue rules as needed.
Hope this helps a bit if not too confusing
Elfizm
And.. I still think it might be.. heh.
Hmm. There's no way for an actor to tell which direction it's being touched (collided) on by another actor, is there?
To collide,
You can say this, if it's your main actor that is colliding, when collide with another object, change the positions of that actor to game.attributes.
Then if self.cloakroom minus game.otherxposition is less then 0
Then direction is going to be right.
If it's more then 0 it's going to be left.
Same principle applies for Y axis.
Is that what you mean, having a main actor?