What do you need a second grid for?
When I place grid Image in Grid I get the grid image in front of the ball.but when I put all two(ball and grid image ) in Grid it doesn't .Is it the right way ?
Added after 25 minutes:
I got it now. will be back with another doubt
Last edited by vinayaka; 22nd June 2011 at 06:31.
You don't have to place each item in a grid. You can place items wherever you want them to be by specifying their X and Y coordinates.
where should and what I write animation to move the ball? (when we click in the grid a ball will be created I want the ball to fall through the grid image at the clicked column and get placed in the empty position). I used to do it using states and transitions but it doesn't work .Is it the right way to do?
Last edited by vinayaka; 23rd June 2011 at 09:47.
Yes, animations and transitions are the correct way to do it
sorry rachol i have to edit the prev post . it DOESN'T work for me.
Have you tried this example: http://doc.qt.nokia.com/latest/qml-s...animation.html ?
vinayaka (23rd June 2011)
Qt Code:
import Qt 4.7 Item { signal clicked states: [ State { name: "a"; PropertyChanges { target: image; source: "pics/balla.png" } }, State { name: "b"; PropertyChanges { target: image; source: "pics/ballb.png" } } ] Image { id: image anchors.centerIn: parent } MouseArea { anchors.fill: parent onClicked: parent.clicked() } }To copy to clipboard, switch view to plain text mode
this is my code for the 2 balls. where should i write animation to move my ball when clicked in a column of my 7X6 grid.
my goal is that if we click in 1st column of the vacant grid it should get placed in last row of that grid and if we again click in the same column ball should get placed 2nd last row the same grid. should I write code in js to get the ball placed? can someone help me?
You need to declare an Animation element that will do the animation itself and then write a piece of javascript code that will setup and trigger the animation. The script should be invoked upon clicking the column (so probably in some MouseArea element).
Qt Code:
Item { signal clicked property bool running: true signal pressed width: board.width/7 height: board.height/5 states: [ State { name: "You"; PropertyChanges { target: image; source: "content/pics/M_CCblackChess.png" } }, State { name: "Computer"; PropertyChanges { target: image; source: "content/pics/M_CCredChess.png" } } ] Transition { to: "you" NumberAnimation { target:image property : "x" from:0 to:boardImage.width/2 -30 duration:1000 easing.type: Easing.OutBack } } Image { id: image anchors.centerIn: parent } MouseArea { id:mousearea anchors.fill: parent //onClicked: parent.clicked() // Animation.running:true onClicked: { if (game.running && Logic.canPlayAtPos(index)) { if (!Logic.makeMove(index, "You")) Logic.computerTurn(); } } } }To copy to clipboard, switch view to plain text mode
hi wysota, did i code in the correct way? if not plz guide me?
Last edited by vinayaka; 28th June 2011 at 08:38.
Not really, I don't see the point of setting up a transition between states. If you want states, then the transition has to occur after a player has made his move, not during that move. You need a simple PropertyAnimation (or similar) that will animate the "y" property of the element clicked.
i don't get what you said. so then what should i do ?If you want states, then the transition has to occur after a player has made his move, not during that move
I have already told you twice. Declare a PropertyAnimation element that will animate the "y" property of a stone. When the player clicks the column when the stone is supposed to be dropped, calculate the value of "y" where the stone should be after the drop, assign the value to the animation, bind the stone item with the animation and trigger the animation.
javascript Code:
import QtQuick 1.0 Rectangle { width: 360 height: 360 Rectangle { id: stone width: 40 height: width radius: width color: "red" border.width: 2 border.color: "black" x: 300 y: 30 smooth: true } PropertyAnimation { id: anim property: "y" } MouseArea { anchors.fill: parent onClicked: { anim.loops = 1 anim.target = stone anim.to = 310 anim.duration = 1000 anim.running = true } } }To copy to clipboard, switch view to plain text mode
thank u wysota
i wrote only animation.running=true. u helped me a lot thanx
vinayaka (29th June 2011)
thanx wysota. but i am not able to open it. it shows error message
Added after 35 minutes:
How can we set a frameless window in qml
Last edited by vinayaka; 29th June 2011 at 07:54.
The archive is corrupt.
Find a better archive manager. The attachment is fine, I just unpacked it without problems.
Bookmarks