qml中关于Particles的碰撞检测
问题在下面注释中,states不能根据Particles的x坐标进行判断,什么原因??
Rectangle {
width: 480
height: 848
color: "black"
/*
Particles {
y: 0
width: parent.width
height: 30
source: "star.png"
lifeSpan: 5000
count: 50
angle: 70
angleDeviation: 36
velocity: 30
velocityDeviation: 10
ParticleMotionWander {
xvariance: 30
pace: 100
}
}
*/
Rectangle{
id:rr1
x:300
y:230
width: 40
height: 50
color: "red"
}
Particles {
id:p1
y: 300
x: 0
width: 50
height: 50
source: "star.png"
lifeSpan: 5000
count: 1
angle: -60//中心角度
angleDeviation: 0//抛撒范围
velocity: 200
velocityDeviation: 0
ParticleMotionGravity {
yattractor: 6360000
xattractor: 0
acceleration: 100
}
}
states: [//下面代码不能很好的工作,求解???
State {
when: (p1.x)<=200//隐藏rr1
//StateChangeScript { script: p1.burst(50); }
PropertyChanges { target: rr1; opacity: 0 }
//StateChangeScript { script: block.destroy(1000); }
},
State {
when: (p1.x)>250//显示rr1
//StateChangeScript { script: p1.burst(50); }
PropertyChanges { target: rr1; opacity: 1 }
//StateChangeScript { script: block.destroy(1000); }
}
]
}