Rexrainbow Board series tutorial #2 Match Detection

5
  • 20 favourites

Index

Attached Files

The following files have been attached to this tutorial:

.png
.capx

Stats

7,418 visits, 15,483 views

Tools

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Chapter 2. Matched-3

~~~~~~~~~~~~~~~~~~

<Matcher> gets information from <Board> to know each position of each chess. We can this procedure "update". When <Matcher> is updating, it will call <On get symbol> automatically. We need to define the symbol of each chess in this event. Why we need to do this? Can't <Board> automatically distinguish each chess by its animation or class type? Of course I think Rexrainbow can do this, but what if someone define his chess by a instance variable? The ways to define a "symbol" for a chess are almost unlimited. So the best choice is the let every designer sets their symbol definitions by theirowns.

In this tutorial, I'd like to set the symbol of each chess by its animation name. Let's change to <Event sheet 1> and add the following codes:

In Event#1, we add an action to setup <Matcher>. This action assigns the correct [Board] to provide information, and assign the [InstGroup] object to save calculation results.

Event#7 runs every 1.0 seconds. Firstly, It finds all patterns which contains 3 continuous symbols in line, and put the result into "match_line" instance group. Secondly, we use [InstGroup] -> <Pick instances> event to pick tiles of matched grid. Because <Matcher> puts only the tile objects into [InstGroup] so we have to select these tiles and then we can pick and flash all the chess above them.

Push <F4> to run layout, most of things are correct, but you may find something a little bit weird:

It seems that <Matcher> found some slant lines, why? Let's look at the properties of [Matcher] object. You'll see by default the <Isometric> property is set to YES. This means your [Matcher] allows a slant matched-3 line which you saw in your layout. Turn it off and everything runs smoothly, now it only detect for horizontal and vertical matched-3 lines:

Look back how many events we've used, 7 events! That's really tiny! In next chapter we will teach you how to detect an L-shaped match. And this will makes our matching logic complete.

  • 0 Comments

  • Order by
Want to leave a comment? Login or Register an account!