开发者

AS3 Array pulling specific information

开发者 https://www.devze.com 2023-04-10 22:21 出处:网络
I am using an array to keep information about 2 blocks that have landed. I then need to pull the spriteoffset from this array. How do I do this? My method below does not work.

I am using an array to keep information about 2 blocks that have landed. I then need to pull the spriteoffset from this array. How do I do this? My method below does not work.

aryBlockRow[(elementbody.yp + elementbody.block[ii].yp)/BLOCKSIZE][(elementbody.xp + elementbody.block[ii].xp)/BLOCKSIZE] = new ElementBlock((elementbody.xp + elementbody.block[ii].xp), (elementbody.yp + elementbody.block[ii].yp), elementbody.block[ii].spriteoffset);

trace("Block row: "+aryBlockRow.block[ii].spriteoffset)

Alternatively, each block has a tag (block[ii].tag), is it possible to pull this information from aryBlockRow, or is it not as I'm not specifically adding it?

Thanks

--

To clarify:

I am creating a tetris style game, however there are 4 different elements. In order to destroy the elements, I need to know when 4 of the same are in a line. The way I am planning to do this is having each of the elements having a variable ("tag") of either 0,1,2 or 3. I am calling the variable elementbody, and within it has an array "block".

            开发者_开发技巧trace("Left tag is: "+elementbody.block[0].tag)
        trace("Right tag is: "+elementbody.block[1].tag)

This returns:

Left tag is: 3 Right tag is: 1

Which is correct.

What I now need to do is be able to continue to trace the tags once the elements have landed. As such, I am placing them into a new Array:

for(ii = 0; ii < elementbody.block.length; ii++) {

aryBlockRow[(elementbody.yp + elementbody.block[ii].yp)/BLOCKSIZE][(elementbody.xp + elementbody.block[ii].xp)/BLOCKSIZE] = new ElementBlock((elementbody.xp + elementbody.block[ii].xp), (elementbody.yp + elementbody.block[ii].yp),
elementbody.block[ii].spriteoffset);

Spriteoffset for each of the blocks (block[0], block[1]) will return either 0, 30, 60 or 90. If I can get this returned, then I can work out whether it has 4 in a row.

What I need to know is: Is it possible to pull "spriteoffset" from the aryBlockRow array, or do I need to somehow store this information elsewhere?

Elementbody changes to the new element everytime it lands on the bottom, and the existing is saved in this array, which is why I can not use my current method.

0

精彩评论

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

关注公众号