Animation of multiple objects

Hello.
I do jigsaw puzzles. At the click of a button, I need to shuffle all the pieces.
To animate of 20 pieces, I need to do 40 actions - Set X and Set Y for each piece.

In each action I wrote:

return Math.random() *0.8.

How can I write all this operations in one code?

For example (this code doesn’t work):

Item {
Connections {
target: widget.scriptAdaptor
onEventItemClicked: {
pageUi.getBlockByName(“D1”).x = Math.random() * 0.8;
pageUi.getBlockByName(“D1”).y = Math.random() * 0.8;

}
}
}

If you share your project I’ll take a look on it.

Here is the working example shuffle_widgets.pma (5.1 KB)

image

Thanks, that’s working!

And how can I animate movement of objects?
In your code is written: document.childByName(“d1”).scriptAdaptor.actionSetX=…

In my project puzzle.pma I’m using “Actions > Animation > Set X”.

Where can I get a description of object model?

Hope it helps

Link to video: https://www.dropbox.com/s/7tegcvleuwofbcm/actions_in_code.mp4?dl=0
Fixed project: puzzle_fixed.pma (3.2 MB)

1 Like

Thank you very much, Michael !


Back to Flipabit >
Copyright © 2018. Flipabit Team. All rights reserved.