ranjit.kadam
5th January 2011, 06:36
Hi friends...I have applied some logic and written code for collision detction using qml...
But Its not yet complete and im stuck and cant move further..so i need your help with this respect..below i m pasting my code..
import Qt 4.7
Rectangle {
id: rect
width: 650; height: 400
color: "#d7d1d1"
Image {
id: image1
property variant direction : "right"
x: 51
y: 30
width: 100
height: 100
transformOrigin: "Center"
z: 26
rotation: -360
scale: 1
source: "qrc:/new/prefix1/2-Pound-Medicine-Ball.jpg"
SequentialAnimation on x {
loops: Animation.Infinite
NumberAnimation { to: rect.width - 10; duration: 2000 }
PropertyAction { target: image1; property: "direction"; value: "left" }
NumberAnimation { to: 10; duration: 2000 }
PropertyAction { target: image1; property: "direction"; value: "right" }
}
}
Image {
id: image2
property variant direction : "right"
x: 364
y: 30
width: 100
height: 100
source: "qrc:/new/prefix1/948709.jpg"
}
function collisiondetection(x1,x2,y1,y2)
{
if(image1.x1>image2.x1 && image1.y1>image2.y1)
return
}
}
so please help me out friends..
regards
Ranjit.Kadam
But Its not yet complete and im stuck and cant move further..so i need your help with this respect..below i m pasting my code..
import Qt 4.7
Rectangle {
id: rect
width: 650; height: 400
color: "#d7d1d1"
Image {
id: image1
property variant direction : "right"
x: 51
y: 30
width: 100
height: 100
transformOrigin: "Center"
z: 26
rotation: -360
scale: 1
source: "qrc:/new/prefix1/2-Pound-Medicine-Ball.jpg"
SequentialAnimation on x {
loops: Animation.Infinite
NumberAnimation { to: rect.width - 10; duration: 2000 }
PropertyAction { target: image1; property: "direction"; value: "left" }
NumberAnimation { to: 10; duration: 2000 }
PropertyAction { target: image1; property: "direction"; value: "right" }
}
}
Image {
id: image2
property variant direction : "right"
x: 364
y: 30
width: 100
height: 100
source: "qrc:/new/prefix1/948709.jpg"
}
function collisiondetection(x1,x2,y1,y2)
{
if(image1.x1>image2.x1 && image1.y1>image2.y1)
return
}
}
so please help me out friends..
regards
Ranjit.Kadam