Results 1 to 17 of 17

Thread: Mobil roll

  1. #1
    Join Date
    Jul 2012
    Posts
    123
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Mobil roll

    Hi,
    I make a program with aim and it move when i roll phone. I try this Sensor but i want roll about 45°.
    Can someone help me?

  2. #2
    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: Mobil roll

    What exactly is the problem?
    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.


  3. #3
    Join Date
    Jul 2012
    Posts
    123
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Mobil roll

    I have next problem i have two MouseArea, first is full background and second is only on one objeck but signals don't work now

  4. #4
    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: Mobil roll

    Please define "don't work".
    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.


  5. #5
    Join Date
    Jul 2012
    Posts
    123
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Mobil roll

    onClicked:
    {
    console.log("this work")
    }
    I never see: "this work"

  6. #6
    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: Mobil roll

    Quote Originally Posted by Viper666 View Post
    onClicked:
    {
    console.log("this work")
    }
    I never see: "this work"
    This is not a valid QML file.
    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.


  7. #7
    Join Date
    Jul 2012
    Posts
    123
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Mobil roll

    i don't understand my code simple
    Qt Code:
    1. import ...
    2. Item {
    3. id: background
    4. MouseArea {
    5. id: mouse
    6. onPositionChanged: {
    7. ...
    8. //something
    9. ...
    10. }
    11. }
    12. Rectangle {
    13. id: rect
    14. MouseArea {
    15. onClicked: { console.log("work") }//this is only test that it's work but it's never emit i never see "work"
    16. }
    17. }
    18. }
    To copy to clipboard, switch view to plain text mode 

  8. #8
    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: Mobil roll

    The code above will make the MouseArea have null size thus you will never hit it.
    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.


  9. #9
    Join Date
    Jul 2012
    Posts
    123
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Mobil roll

    i forgot anchors.fill: parent but it it there in each mousearea

  10. #10
    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: Mobil roll

    In that case your first mouse area overlaps with the second one and overrides it. Thus the first mouse area will work and the second one will not.
    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.


  11. #11
    Join Date
    Jul 2012
    Posts
    123
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Mobil roll

    ok i will make it else i have duck and i have own crosshair and shotbutton how can i do thath when you press shotbutton you will shot duck i can't use something like if(duck.x == aim.x && duck.y == aim.y) because i want full duck and not only one pixel?
    Do you understand me sorry my English is horrible .

  12. #12
    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: Mobil roll

    I don't understand what you mean. And it's not about the language, it's more about the content of your posts. You should really post a minimal complete example that demonstrates the problem.
    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.


  13. #13
    Join Date
    Jul 2012
    Posts
    123
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Mobil roll

    Ok i make a game first time. I want simple game you must shot duck. And i don't know how make it. When you shot how can i detect that you shot duck
    i can't use if(click.y == duck.y && click.x == duck.x) because you never click on this one pixel. So how can i do that? My first idea: Duck { MouseArea { id: mouse; onClicked: { console.log("shot"); }} but this is wrong because i have a aim(crosshair) image

  14. #14
    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: Mobil roll

    I'd have to see some real code to be able to comment on it. I don't know how the crosshair is related to the action of "shooting". Are you "aiming" by hovering mouse and "shooting" by clicking it?
    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.


  15. #15
    Join Date
    Jul 2012
    Posts
    123
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Mobil roll

    Quote Originally Posted by wysota View Post
    Are you "aiming" by hovering mouse and "shooting" by clicking it?
    Yes but now how detect that player shoot the duch?

  16. #16
    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: Mobil roll

    Here is one possibility:

    javascript Code:
    1. import QtQuick 1.1
    2.  
    3. Rectangle {
    4. id: root
    5. width: 360
    6. height: 360
    7.  
    8. Rectangle {
    9. property bool hit: false
    10. id: duck
    11. width: 50
    12. height: width
    13. radius: width/2
    14. color: "red"
    15. y: 60
    16. NumberAnimation on x {
    17. duration: 3000
    18. from: 0
    19. to: root.width
    20. loops: NumberAnimation.Infinite
    21. running: !duck.hit
    22. }
    23. NumberAnimation on y {
    24. duration: 500
    25. to: root.height
    26. running: duck.hit
    27. }
    28. }
    29.  
    30. Rectangle {
    31. id: crosshair
    32. width: 40
    33. height: width
    34. border.color: "black"
    35. border.width: 1
    36. color: "transparent"
    37. }
    38.  
    39. MouseArea {
    40. id: aim
    41. anchors.fill: parent
    42. hoverEnabled: true
    43. onPositionChanged: {
    44. crosshair.x = mouse.x-crosshair.width/2
    45. crosshair.y = mouse.y-crosshair.height/2
    46. }
    47. onClicked: {
    48. if(mouse.x >= duck.x && mouse.x <= duck.x+duck.width && mouse.y >= duck.y && mouse.y <= duck.y+duck.height) {
    49. duck.hit = true
    50. }
    51. }
    52.  
    53. }
    54. }
    To copy to clipboard, switch view to plain text mode 

    Here is another:

    javascript Code:
    1. import QtQuick 1.1
    2.  
    3. Rectangle {
    4. id: root
    5. width: 360
    6. height: 360
    7.  
    8. Rectangle {
    9. property bool hit: false
    10. id: duck
    11. width: 50
    12. height: width
    13. radius: width/2
    14. color: "red"
    15. y: 60
    16. NumberAnimation on x {
    17. duration: 3000
    18. from: 0
    19. to: root.width
    20. loops: NumberAnimation.Infinite
    21. running: !duck.hit
    22. }
    23. NumberAnimation on y {
    24. duration: 500
    25. to: root.height
    26. running: duck.hit
    27. }
    28. MouseArea {
    29. anchors.fill: parent
    30. onClicked: duck.hit = true
    31.  
    32. }
    33. }
    34.  
    35. Rectangle {
    36. id: crosshair
    37. width: 40
    38. height: width
    39. border.color: "black"
    40. border.width: 1
    41. color: "transparent"
    42. }
    43.  
    44. MouseArea {
    45. id: aim
    46. anchors.fill: parent
    47. hoverEnabled: true
    48. acceptedButtons: Qt.NoButton
    49. onPositionChanged: {
    50. crosshair.x = mouse.x-crosshair.width/2
    51. crosshair.y = mouse.y-crosshair.height/2
    52. }
    53.  
    54. }
    55. }
    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.


  17. #17
    Join Date
    Jul 2012
    Posts
    123
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Mobil roll

    i need this thanks

Similar Threads

  1. the mouse's wheel roll problem in embedded linux
    By lzpmail in forum Qt Programming
    Replies: 2
    Last Post: 4th January 2012, 10:15

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.