本文介绍了添加一个额外的图层到我的js genarated“检查”板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下小提琴(点击1看板):

I have the following fiddle (click the 1 to see the board):http://jsfiddle.net/mauricederegt/vNpYe/1/

这部分代码:

 this.getHTML = function () {
        return '<div class="tile tile' + this.type + '" style="left:' + this.x + 'px; top:' + this.y + 'px"></div>';
    };

使用以下代码生成checkers板:

generates the "checkers" board using this code:

var levels = [
    [ //lvl1
        //layer1
        [1, 2, 1],
        [0, 0, 0, 0, 0, 0],
        [2, 1, 2],
        [0, 0, 0, 0, 0, 0],
        [1, 2, 1],
        [0, 0, 0, 0, 0, 0]
        //layer2
        //[0, 3, 4],
        //[0, 0, 0, 0, 0],
        //[0,4,3],
        //[0, 0, 0, 0, 0]
    ],
    [ //lvl2
        [1,2,0,1,2,1],
        [1, 2]
    ]

];

目前有一层。我想在这第一层的顶部添加一个额外的层。基本上在这个板的顶部(和更多层以后)。这个板的代码应该看起来像这样:

Currently it has one layer. I want to add an extra layer on top of this first layer. Basically ad a board on top of this board (and more layers later on). The code of this board should look something like this:

//layer2
  [0, 3, 4],
  [0, 0, 0, 0, 0],
  [0, 4, 3],
  [0, 0, 0, 0, 0]

如果尝试将它放在额外的标签{},所以它会完成之间的循环之间,然后去level2,让它工作。玩了z-index一点,也没有运气。非常感谢任何帮助。

If tried putting it in extra tags { }, so it would finish the cycle between it first before going to level2, but couldn't get it to work. Played with z-index a bit, also no luck. Any help would be greatly appreciated

感谢

推荐答案

您的第1层图层都在同一个级别...

Note that your layers for level 1 are all on the same "level"...

查看更正版本:

var levels = [
    [ //level one
        [//layer one of level one
            [1, 2, 1],
            [0, 0, 0, 0, 0, 0],
            [2, 1, 2],
            [0, 0, 0, 0, 0, 0],
            [1, 2, 1],
            [0, 0, 0, 0, 0, 0]
        ],
        [ //layer one of level one
           [0, 3, 4],
           [0, 0, 0, 0, 0],
           [0,4,3],
           [0, 0, 0, 0, 0]
        ]
    ],
    [ //level two
        [//layer one of level two
            [1,2,0,1,2,1],
            [1, 2]
        ]
    ]

];

这篇关于添加一个额外的图层到我的js genarated“检查”板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 11:14