跳至主要內容

初始化旋轉座標系 (screen.init)

聲明

原座標系 = screen.init(座標系)

參數

  • 座標系
    整數型
    0 表示直向 home 在下
    1 表示橫向 home 在右
    2 表示橫向 home 在左
    3 表示直向 home 在上

回傳值

  • 原座標系
    整數型,返回這個函式呼叫之前使用的座標系

說明

初始化取色或點選的座標系,會影響以下函式座標參數及回傳值的含義:

screen.get_color
screen.is_colors
screen.find_color
screen.ocr_text
screen.image
touch.on
touch.move
touch.off
touch.tap

以 iPhone 8 為例 (750x1334 分辨率):

預設直向座標系是這樣的 screen.init(0)
(0,0) 實體左上角
┌──────────────────────────────────▶ x+
│ │

│ │

│ │

│ │

│ │

│ │

│ │

│ │

│ │
│ │
▼ y+ ▼
(750,1334) 實體右下角
┌──────────────────────────────────┐
│ Home │
└──────────────────────────────────┘
橫向 Home 在右是這樣的 screen.init(1)
 (0,0)
┌────────────────────────────────────────────────▶ x+ 實體右下角
│ │ ┌───┐
│ │ │
│ │ │ │
│ │ │
│ │ │ │
│ │ H │
│ │ │ o │
│ │ m │
│ │ │ e │
│ │ │
│ │ │ │
│ │ │
│ │ │ │
│ │ └───┘
▼ y+ ▼
實體左上角 (1334,750)
橫向 Home 在左是這樣的 screen.init(2)
      (0,0)
┌────────────────────────────────────────────────▶ x+ 實體左上角
┌───┐ │ │
│ │ │
│ │ │ │
│ │ │
│ │ │ │
│ H │ │
│ o │ │ │
│ m │ │
│ e │ │ │
│ │ │
│ │ │ │
│ │ │
│ │ │ │
└───┘ │ │
▼ y+ ▼
實體右下角 (1334,750)
直向 Home 在上是這樣的 screen.init(3)
   ┌──────────────────────────────────┐
│ Home │
└──────────────────────────────────┘
(0,0) 實體右下角
┌──────────────────────────────────▶ x+
│ │

│ │

│ │

│ │

│ │

│ │

│ │

│ │

│ │
│ │
▼ y+ ▼
(750,1334) 實體左上角

範例

screen.init(0)    -- home 在下
screen.init(1) -- home 在右
screen.init(2) -- home 在左
screen.init(3) -- home 在上

使用以下別名呼叫也可以實現相同效果

screen.init_home_on_bottom()    -- home 在下
screen.init_home_on_right() -- home 在右
screen.init_home_on_left() -- home 在左
screen.init_home_on_top() -- home 在上