I am trying to make an app with QML for Ubuntu Touch that is similar to the game Avalanche, and am unsure how to go about inserting a varying number of falling blocks. All of the blocks will be the same picture, but will have different sizes and IDs. The blocks will also be deleted when they go off screen (so they don't fill up any more RAM to store their sizes, IDs, etc. when they are no longer needed). Here is the template for the blocks that I would like to use:
Image {
id: block0 //The first block will be 0, the second 1, the third 2, and so on
source: "block.png"
height: units.gu(Math.floor(Math.random) * 5 + 1)
width: height
x: units.gu(Math.floor(Math.random() * (75 - width)))
}
So, how can I have this code snippet be written to and deleted from the QML file when the game is played? I would like to do this with JavaScript so it will be easier to make the IDs and store them in an array to easily access information. Sorry if this is difficult to understand, and thanks for the help!