Page 2 of 3 FirstFirst 123 LastLast
Results 21 to 40 of 51

Thread: 4 in a row

  1. #21
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: 4 in a row

    What do you need a second grid for?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  2. #22
    Join Date
    May 2011
    Posts
    120
    Thanks
    33
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: 4 in a row

    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.

  3. #23
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: 4 in a row

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #24
    Join Date
    May 2011
    Posts
    120
    Thanks
    33
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: 4 in a row

    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.

  5. #25
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    164
    Thanks
    1
    Thanked 26 Times in 26 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: 4 in a row

    Yes, animations and transitions are the correct way to do it

  6. #26
    Join Date
    May 2011
    Posts
    120
    Thanks
    33
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: 4 in a row

    sorry rachol i have to edit the prev post . it DOESN'T work for me.

  7. #27
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    164
    Thanks
    1
    Thanked 26 Times in 26 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: 4 in a row


  8. The following user says thank you to Rachol for this useful post:

    vinayaka (23rd June 2011)

  9. #28
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: 4 in a row

    Declare an animation element, attach it to your ball and run the animation.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #29
    Join Date
    May 2011
    Posts
    120
    Thanks
    33
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: 4 in a row

    Qt Code:
    1. import Qt 4.7
    2.  
    3. Item {
    4. signal clicked
    5.  
    6. states: [
    7. State { name: "a"; PropertyChanges { target: image; source: "pics/balla.png" } },
    8. State { name: "b"; PropertyChanges { target: image; source: "pics/ballb.png" } }
    9. ]
    10.  
    11. Image {
    12. id: image
    13. anchors.centerIn: parent
    14. }
    15.  
    16. MouseArea {
    17. anchors.fill: parent
    18. onClicked: parent.clicked()
    19. }
    20. }
    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?

  11. #30
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: 4 in a row

    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).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  12. #31
    Join Date
    May 2011
    Posts
    120
    Thanks
    33
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: 4 in a row

    Qt Code:
    1. Item {
    2. signal clicked
    3. property bool running: true
    4. signal pressed
    5.  
    6. width: board.width/7
    7. height: board.height/5
    8.  
    9.  
    10. states: [
    11. State { name: "You"; PropertyChanges { target: image; source: "content/pics/M_CCblackChess.png" } },
    12. State { name: "Computer"; PropertyChanges { target: image; source: "content/pics/M_CCredChess.png" } }
    13. ]
    14.  
    15. Transition {
    16. to: "you"
    17.  
    18.  
    19.  
    20.  
    21. NumberAnimation {
    22. target:image
    23. property : "x"
    24. from:0
    25. to:boardImage.width/2 -30
    26. duration:1000
    27. easing.type: Easing.OutBack
    28.  
    29. }
    30.  
    31.  
    32.  
    33. }
    34.  
    35. Image {
    36. id: image
    37. anchors.centerIn: parent
    38. }
    39.  
    40. MouseArea {
    41. id:mousearea
    42. anchors.fill: parent
    43. //onClicked: parent.clicked()
    44. // Animation.running:true
    45. onClicked: {
    46. if (game.running && Logic.canPlayAtPos(index)) {
    47.  
    48. if (!Logic.makeMove(index, "You"))
    49. Logic.computerTurn();
    50. }
    51. }
    52.  
    53.  
    54.  
    55. }
    56. }
    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.

  13. #32
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: 4 in a row

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  14. #33
    Join Date
    May 2011
    Posts
    120
    Thanks
    33
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: 4 in a row

    If you want states, then the transition has to occur after a player has made his move, not during that move
    i don't get what you said. so then what should i do ?

  15. #34
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: 4 in a row

    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:
    1. import QtQuick 1.0
    2.  
    3. Rectangle {
    4.  
    5. width: 360
    6. height: 360
    7.  
    8. Rectangle {
    9. id: stone
    10. width: 40
    11. height: width
    12. radius: width
    13. color: "red"
    14. border.width: 2
    15. border.color: "black"
    16. x: 300
    17. y: 30
    18. smooth: true
    19. }
    20. PropertyAnimation {
    21. id: anim
    22. property: "y"
    23.  
    24.  
    25. }
    26.  
    27. MouseArea {
    28. anchors.fill: parent
    29. onClicked: {
    30. anim.loops = 1
    31. anim.target = stone
    32. anim.to = 310
    33. anim.duration = 1000
    34. anim.running = true
    35. }
    36. }
    37. }
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  16. #35
    Join Date
    May 2011
    Posts
    120
    Thanks
    33
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: 4 in a row

    thank u wysota
    i wrote only animation.running=true. u helped me a lot thanx

  17. #36
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: 4 in a row

    Here is my implementation of the game. Somewhat crude but it works.
    Attached Files Attached Files
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  18. The following user says thank you to wysota for this useful post:

    vinayaka (29th June 2011)

  19. #37
    Join Date
    May 2011
    Posts
    120
    Thanks
    33
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: 4 in a row

    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.

  20. #38
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: 4 in a row

    Quote Originally Posted by vinayaka View Post
    thanx wysota. but i am not able to open it. it shows error message
    What error?

    How can we set a frameless window in qml
    We can't since qml doesn't deal with windows. You have to do that in C++.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  21. #39
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    164
    Thanks
    1
    Thanked 26 Times in 26 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: 4 in a row

    The archive is corrupt.

  22. #40
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: 4 in a row

    Find a better archive manager. The attachment is fine, I just unpacked it without problems.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.