首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > QT开发 >

qml中关于Particles的碰撞检测解决方法

2013-01-17 
qml中关于Particles的碰撞检测问题在下面注释中,states不能根据Particles的x坐标进行判断,什么原因??Recta

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); }
             }
         ]
     }


[解决办法]
引用:
问题在下面注释中,states不能根据Particles的x坐标进行判断,什么原因??
C/C++ code?12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667Rectangle {        ……


可以进行图片内的判断。

热点排行