开发者

check if a movieclip exists on a specific location relative to event.currentTarget

开发者 https://www.devze.com 2023-04-06 11:55 出处:网络
How can I check if the stage contains a movieclip on a specific x and y location on the stage? I\'m building a colour-guessing game. The purpose is to walk a path through a generated field of hexagon

How can I check if the stage contains a movieclip on a specific x and y location on the stage?

I'm building a colour-guessing game. The purpose is to walk a path through a generated field of hexagons, each assigned a random colour (yellow, red, blue or green), based on what soundfile you hear. So if you hear "yellow", you have to click a yellow tile etc.

But because I want it to be a path, and the colours of the tiles are randomly generated, I have to check which colours border the currently active tile. I literally have no idea how to do this.

I thought this might work but it doesnt:

if ((this.tile.y == (event.currentTarget.y - 64)) != null) { 
    //add the colour of this tile to array
}

I also see some problems in how to check if the next tile clicked borders on the previously active tile :( It's getting slightly overcomplicated for me. I would really appreciate your views on this.

开发者_如何学Go

So my current question is: how do I check if a tile exists on stage that borders my active tile?

Edit again: the game should be a simpler version of this one: http://elt.oup.com/student/i-spy/games/colour


I'm not 100% sure about the situation, but I think you should add an eventListener on these tiles so that if you click on them, the color is checked with the current color that has to be clicked. Are you working actionscript 3 based? This shouldn't be to hard but it's hard to explain.


When you randomly generate your tiles, store them. You may find that a linked list or doubly linked list works well for this--if you have a reference to the tile, you automatically have a reference to the bordering tile(s) http://www.developria.com/2009/12/iterative-data-storage-in-as3.html

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号