2017-07-14 38 views
0

我正在使用的LiveCode應用程序中的其中一張卡片的屏幕截圖如下所示。用戶可以點擊圖標並將它們移動到屏幕上,理想情況下可以使用右側的框對它們進行排序。爲了記錄圖標的排名,我想要得到它們的y座標 - 也就是說,y座標值越高,排名越低。儘管如此,我很難將圖像的座標傳遞給變量。我對LiveCode相當陌生,因此非常感謝任何幫助。 rating_screenshot在LiveCode中傳遞圖像的x,y座標

回答

0

歡迎使用LiveCode!

在LiveCode你有一個屬性:

the loc of image 」imagename」

,你可以通過作爲變量的過程。這將包含用逗號分隔的圖像(或任何控件)的x 。爲了得到y,你需要得到第二個項目。所以你可以在你的程序中抓取它,或者直接通過它。假設您有一個名爲saveOrder的過程,您可以通過某種方式保存您的數據。在你可以調用與y座標,如:

saveOrder item 2 of the loc of image 「imagename」 

如果你只是想抓住的東西,以確定哪些圖片是高於其他的你可以改用the topthe bottom代替item 2 of the loc。看他們在字典中對進一步的解釋...

PS the loc是短期的the location,當然你可以,如果你喜歡它

+0

@ hliljegren - 非常感謝!順便說一下,在LiveCode中也可以在OOP上欣賞你的帖子。 – credenzamatic

0

只是一個練習寫出來:在新卡讓兩個按鈕。在卡片腳本中:

on mouseMove 
    if "button" is in the name of the target and the mouse is down then 
    set the loc of the target to the mouseLoc 
    put item 2 of the loc of the target 
    end if 
end mouseMove 

單擊並拖動鼠標左鍵。拖動時,按鈕中心的「Y」座標將出現在消息框中。當然,當你釋放時,最後一個座標將會停止。

正如hliljegren指出的那樣,你可能不希望中心,而是控制利率的頂部或其他點。

0

你只需要:

on MouseDown 
    grab me 
end MouseDown 

Livecode是世界上最簡單,最有效的語言!