Pattern

massoudn

کاربر فعال
Depth Management in AS3

  1. // create a new depth manager instance
  2. _depthmanager = new dodepthmanager(_boxesholder);
  3. // create an array of colors, red, green, blue
  4. var _colors:array = [0xff0000, 0x00ff00, 0x0000ff];
  5. // give the red box a depth of 2
  6. var _targetdepth:int = 2;
  7. var _centerstagex:number = this.stage.stagewidth * .5;
  8. var _centerstagey:number = this.stage.stageheight * .5;
  9. for(var i:int = 0; i < 3; i++) {
  10. // fill the boxes, red, green, then blue
  11. var _box:sprite = _createsquare(_colors);
    [*]// place randomly
    [*]_box.x = (_centerstagex * .4) + ( i * 6);
    [*]_box.y = (_centerstagey * .4) + (i * -12);
    [*]// add the red box at depth 2, green box at depth 1, and blue box at depth 2
    [*]_depthmanager.adddepth(_box, _targetdepth);
    [*]_targetdepth--;
    [*]}
    [*]// now create a yellow box
    [*]var _yellowbox:sprite = _createsquare(0xffff00);
    [*]_yellowbox.x = _centerstagex;
    [*]_yellowbox.y = _centerstagey;
    [*]// and stick it in the middle, at a pre-occupied depth
    [*]_depthmanager.adddepth(_yellowbox, 2);
    [*]
    [*]// add the subscribed displayobjects to the scope's displaylist
    [*]_depthmanager.addchildrenbydepth();

 

پیوست ها

  • Depth Manager.zip
    792.6 کیلوبایت · بازدیدها: 18

جدیدترین ارسال ها

بالا