简体   繁体   中英

I'd like to select an Image View with one click and then add a duplicated image view to another view with a second click.

For our purposes, let's think of it as a chess game. So I touch the queen and click it, then I touch the square that I'd like to move the queen to and the queen moves to that square.

I think this is a pretty simple task, but I've searched high and low for an answer but yet to find one.
Original I was using an OnTouchListener and Drag and Drop, but it will work much better with OnClick so that the user clicks twice to move the object. (I think)

Thanks for the help.

Setup an OnClickListener and a variable to hold the selected field. onClick, check if there is already a field selected, if not, store the clicked field in the variable. If there is already a selected field stored, move the piece from the stored field to the clicked field and clear the variable to allow a new move. You can apply your game logic/rules in the second branch too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM