Rexrainbow Board series tutorial #2 Match Detection

5

Index

Attached Files

The following files have been attached to this tutorial:

.png
.capx

Stats

7,500 visits, 15,612 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.

Published on 25 Feb, 2016. Last updated 19 Feb, 2019

Chapter 1. Prepare a New Project

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

There are a lot of people asking about "how to make a match-3 game?". Now Rexrainbow <Board> series plugins are the perfect solution for this question. In this tutorial, we will teach you how to detect matched chess in line and in L-shape. And you'll find the power of <Board> series plugins.

Before we start the core lessons, we need a new project. We've done this in last tutorial so now you should be familiar with this. Create a bland project and set its Window size to (480,854). This time we need a portrait window.

Drag <tile.png> into project. This creates a [tile] object which we will take it as the tile for our board. Set its (w, h) to (64, 64).

Drag <chess.png> into project. This creates a [chess] object which we will take it as the chess for our board. Set it (w, h) to (64, 64), too.

Double click on [chess] object to edit its image. Rename its animation name to "blue". Add 3 new animations and name them: green, red, yellow. Load corresponding assets into these animations.

Add a <Flash> behavior for [chess]. Later we'll need this behavior to indicate which chess are matched.

Back to <Layout 1>, add 4 Rexrainbow plugins: <Board>, <SquareTx>, <InstGroup>, and <Matcher>.

Set [Board] parameters. We need a 7 x 12 board.

Set [SquareTx] parameters.

Change to <Event sheet 1> and start to code:

You can see that comparing to last tutorial, we introduced some new instructions here:

In Event#1, we use <Board>-><Fill tiles> actions to fill tile on every grid. This is realy handy.

In Event#2, we use <Board>-><For each cell> condition as an iterator and set direction parameter to <Top to bottom>. This make the interator sweep from top to bottom in row, and left to right in column. In each loop we create a chess at (x, y, z) = (Board.CurLX, Board.CurLX, 1). And we use choose() expression to randomly choose one animation for us.

Push <F4> to run layout, you'll get a beatiful board like below:

As you can see, there are several sets of pattern which would be considered "matched" in a match-3 game. In next chapter, we will teach you how to detect these patterns by <Matcher> plugin.

  • 0 Comments

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