課程
/前端開發
/WebApp
/慕課網2048私人訂制
function updateBoardView()這個函數怎么寫
2014-10-31
源自:慕課網2048私人訂制 2-3
正在回答
function updateBoardView(){ ? ?$(".num-cell").remove(); ? ?for(var i =0;i < 4;i++){ ? ? ? ?for(var j = 0;j < 4;j++){ ? ? ? ? ? ?$("#grid-container").append('<div class="number-cell" id="number-cell-'+i+'-'+j+'"></div>'); ? ? ? ? ? ?var theNumberCell = $('number-cell-'+i+'-'+j); ? ? ? ? ? ?if (board[i][j] == 0){ ? ? ? ? ? ? ? ?theNumberCell.css("width","0px"); ? ? ? ? ? ? ? ?theNumberCell.css("height","0px"); ? ? ? ? ? ? ? ?theNumberCell.css("top",getPosTop(i,j)+50); ? ? ? ? ? ? ? ?theNumberCell.css("left",getPosLeft(i,j)+50); ? ? ? ? ? ?}else{ ? ? ? ? ? ? ? ?theNumberCell.css("width","100px"); ? ? ? ? ? ? ? ?theNumberCell.css("height","100px"); ? ? ? ? ? ? ? ?theNumberCell.css("top",getPosTop(i,j)); ? ? ? ? ? ? ? ?theNumberCell.css("left",getPosLeft(i,j)); ? ? ? ? ? ? ? ?theNumberCell.css("background-color",getNumberBackgroundColor( board[i],[j] )); ? ? ? ? ? ? ? ?theNumberCell.css("color",getNumberColor( board[i],[j] )); ? ? ? ? ? ? ? ?theNumberCell.text(board[i],[j]); ? ? ? ? ? ?} ? ? ? ?} ? ?}}
舉報
慕課網這款“2048私人訂制”通過大神老的講解學習到游戲結構的開發
2 回答老師這個demo還有bug
1 回答chrome里面手機模擬器的左右和手機上的觸控左右是相反的
1 回答老師寫的for 循環 變成加 { }的形式,是在for 循環外return true 還是內部的某部循環return true ?
2 回答怎么處理連加問題?原版的好像是不能連加的
1 回答新建.c文件不能運行
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2016-09-03
function updateBoardView(){
? ?$(".num-cell").remove();
? ?for(var i =0;i < 4;i++){
? ? ? ?for(var j = 0;j < 4;j++){
? ? ? ? ? ?$("#grid-container").append('<div class="number-cell" id="number-cell-'+i+'-'+j+'"></div>');
? ? ? ? ? ?var theNumberCell = $('number-cell-'+i+'-'+j);
? ? ? ? ? ?if (board[i][j] == 0){
? ? ? ? ? ? ? ?theNumberCell.css("width","0px");
? ? ? ? ? ? ? ?theNumberCell.css("height","0px");
? ? ? ? ? ? ? ?theNumberCell.css("top",getPosTop(i,j)+50);
? ? ? ? ? ? ? ?theNumberCell.css("left",getPosLeft(i,j)+50);
? ? ? ? ? ?}else{
? ? ? ? ? ? ? ?theNumberCell.css("width","100px");
? ? ? ? ? ? ? ?theNumberCell.css("height","100px");
? ? ? ? ? ? ? ?theNumberCell.css("top",getPosTop(i,j));
? ? ? ? ? ? ? ?theNumberCell.css("left",getPosLeft(i,j));
? ? ? ? ? ? ? ?theNumberCell.css("background-color",getNumberBackgroundColor( board[i],[j] ));
? ? ? ? ? ? ? ?theNumberCell.css("color",getNumberColor( board[i],[j] ));
? ? ? ? ? ? ? ?theNumberCell.text(board[i],[j]);
? ? ? ? ? ?}
? ? ? ?}
? ?}
}