zoukankan      html  css  js  c++  java
  • 另一种换行排列方块的方法

    换行排列:

    //设定第一个方块的位置
    var xPosition:Number=5;
    var yPosition:Number=5;
    
    for (var i:int=0; i<30; i++) {
    	var eee:EEE=new EEE();
    	eee.tf_label.text=String(i);
    	addChild(eee);
    	eee.x=xPosition;
    	eee.y=yPosition;
    	xPosition+=eee.width+5;//提前获得下一个方块的x坐标,然后在下面判断,如果下一个方块的x坐标+宽度>600,则让其排在第二行,x坐标和第一行第一个方块一样,为5
    	if (xPosition+eee.width>600) {
    		xPosition=5;
    		yPosition+=eee.height+5;
    	}
    }
    

    换列排列:

    //设定第一个方块的位置
    var xPosition:Number=5;
    var yPosition:Number=5;
    
    for (var i:int=0; i<30; i++) {
    	var eee:EEE=new EEE();
    	eee.tf_label.text=String(i);
    	addChild(eee);
    	eee.x=xPosition;
    	eee.y=yPosition;
    	yPosition+=eee.height+5;//提前获得下一个方块的y坐标,然后在下面判断,如果下一个方块的y坐标+高度>400,则让其排在第二列,,y坐标和第一行第一个方块一样,为5
    	if (yPosition+eee.height>400) {
    		yPosition=5;
    		xPosition+=eee.width+5;
    	}
    }
    
  • 相关阅读:
    501. Find Mode in Binary Search Tree
    [leetcode]Evaluate Reverse Polish Notation
    [leetcode]LRU Cache
    [mock]12月27日
    [mock]12月28日
    [leetcode]Max Points on a Line
    *[topcoder]JumpFurther
    [mock]12月11日
    *[topcoder]GUMIAndSongsDiv1
    [leetcode]Reorder List
  • 原文地址:https://www.cnblogs.com/leon3286/p/1787028.html
Copyright © 2011-2022 走看看