其他分享
首页 > 其他分享> > pixijs 点击穿透支持png图片识别透明通道

pixijs 点击穿透支持png图片识别透明通道

作者:互联网

        function onDragStart(event){
                  this.data = event.data;
        var dianjix = this.data.global.x;
        var dianjiy = this.data.global.y;
                  console.log('dianjix:'+dianjix);
                  console.log('dianjiy:'+dianjiy);

   var appAllChildren = app.stage.children
            var acNum = appAllChildren.length
            for (var i = 0; i < acNum; i++) {
                        if(appAllChildren[i].isSprite){
   var baoweihe=appAllChildren[i].getBounds();
                    console.log(baoweihe);
                     var isdianji = isCollsion(dianjix, dianjiy, baoweihe.x, baoweihe.y, baoweihe.width, baoweihe.height);
                     if(isdianji){

                         //获取点击的像素是不是透明的
                         var touchinx=parseInt(dianjix-baoweihe.x);
                         var touchiny=parseInt(dianjiy-baoweihe.y);
                         var xiangsucount=(touchinx+1)*(touchiny+1);
                        
                       //注意这个输出的像素是按照原来图片本身的大小来的
                        var ss=app.renderer.extract.pixels(appAllChildren[i]);
                        console.log(ss);
                        var xiangsuindex=(xiangsucount-1)*4+3;

                        // var xiangsutouming=ss[xiangsutouming];
                        // alert(xiangsutouming);
                          
                     }


                        }
              
                 

              }

             }

 

标签:console,appAllChildren,baoweihe,dianjiy,穿透,dianjix,var,pixijs,png
来源: https://www.cnblogs.com/newmiracle/p/13847775.html