At the start of a game, or when you want to reset the game field, you will call this method to set up a new tile set:
game
class will be named CreateAtomElements
.Method CreateAtomElements:Int()
Millisecs
.Seed = Millisecs()
23
pixels and stored inside a local variable.Local cd:Int = 23
For
loops for this purpose.For Local y:Int = 1 To 11 For Local x:Int = 1 To 8
Local ek:Int = (Rnd(0,3)+0.4)
ek
value to a different one. This depends on another random number call with a range from 0 to 100.If ek = 2 And Rnd(0,100) > 20 Then ek = 3 If ek = 1 And Rnd(0,100) > 80 Then ek = 0
For a little bit of eye candy, we want to add some kind of sprite animation. Here, we will use the CreateAnimImage
method of fantomEngine.
ek
value. For each sprite, we have four different anim images.Local tile:ftObject = eng.CreateAnimImage(atlas, 0 ,ek*32 ,32,32, 4, x*48+24, y*48+88)
grpAtom
.tile.SetTag(grpAtom)
layerGame
.tile.SetScale(1.5) tile.SetLayer(layerGame)
0
. Later, we will store the current collCount
value in it.tile.SetID(0)
tile.SetTouchMode(2)
Select ek Case 0 CreateColCircle(tile,x*48+24, y*48+88-cd) Case 1 CreateColCircle(tile,x*48+24, y*48+88-cd) CreateColCircle(tile,x*48+24, y*48+88+cd) Case 2 CreateColCircle(tile,x*48+24, y*48+88-cd) CreateColCircle(tile,x*48+24+cd, y*48+88) CreateColCircle(tile,x*48+24-cd, y*48+88) Case 3 CreateColCircle(tile,x*48+24, y*48+88-cd) CreateColCircle(tile,x*48+24+cd, y*48+88) End
Local f:Int = (Rnd(0,3)+0.4)+1
5
units.tile.SetAnimTime(5)
f
.tile.SetAnimFrame(f)
Local a:Int = (Rnd(0,3)+0.4) tile.SetAngle(a*90.0)
For
loops and the method.Next Next Return 0 End
We just created two methods that let us dynamically build a grid of atom elements and their corresponding child collision detectors.
3.136.17.12