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?
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?
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
onClicked:
{
console.log("this work")
}
I never see: "this work"![]()
i don't understand my code simple
Qt Code:
import ... Item { id: background MouseArea { id: mouse onPositionChanged: { ... //something ... } } Rectangle { id: rect MouseArea { onClicked: { console.log("work") }//this is only test that it's work but it's never emit i never see "work" } } }To copy to clipboard, switch view to plain text mode
i forgot anchors.fill: parent but it it there in each mousearea
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.
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 .
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.
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
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?
Here is one possibility:
javascript Code:
import QtQuick 1.1 Rectangle { id: root width: 360 height: 360 Rectangle { property bool hit: false id: duck width: 50 height: width radius: width/2 color: "red" y: 60 NumberAnimation on x { duration: 3000 from: 0 to: root.width loops: NumberAnimation.Infinite running: !duck.hit } NumberAnimation on y { duration: 500 to: root.height running: duck.hit } } Rectangle { id: crosshair width: 40 height: width border.color: "black" border.width: 1 color: "transparent" } MouseArea { id: aim anchors.fill: parent hoverEnabled: true onPositionChanged: { crosshair.x = mouse.x-crosshair.width/2 crosshair.y = mouse.y-crosshair.height/2 } onClicked: { if(mouse.x >= duck.x && mouse.x <= duck.x+duck.width && mouse.y >= duck.y && mouse.y <= duck.y+duck.height) { duck.hit = true } } } }To copy to clipboard, switch view to plain text mode
Here is another:
javascript Code:
import QtQuick 1.1 Rectangle { id: root width: 360 height: 360 Rectangle { property bool hit: false id: duck width: 50 height: width radius: width/2 color: "red" y: 60 NumberAnimation on x { duration: 3000 from: 0 to: root.width loops: NumberAnimation.Infinite running: !duck.hit } NumberAnimation on y { duration: 500 to: root.height running: duck.hit } MouseArea { anchors.fill: parent onClicked: duck.hit = true } } Rectangle { id: crosshair width: 40 height: width border.color: "black" border.width: 1 color: "transparent" } MouseArea { id: aim anchors.fill: parent hoverEnabled: true acceptedButtons: Qt.NoButton onPositionChanged: { crosshair.x = mouse.x-crosshair.width/2 crosshair.y = mouse.y-crosshair.height/2 } } }To copy to clipboard, switch view to plain text mode
i need this thanks
Bookmarks