Пример #1
0
            function shotCueBall() {
                _this.table.unbind("mousemove",showGuide);
                _this.table.unbind("mouseup",shotCueBall);
                var formPos = util.getBallPos(_this.cueBall.elem),

                toPos = util.getBallPos(_this.guideBall),

                angle = Math.atan2(toPos[0] - formPos[0], toPos[1] - formPos[1]);

                $(_this.dotWrap).hide();
                _this.cueBall.v = util.speed;
                _this.cueBall.angle = angle;
                _this.movingballs.push(_this.cueBall);
                $(_this.guideBall).hide();
                _this.cueBall.move(_this.balls, _this.movingballs, _this.startShot);
            }
Пример #2
0
                function drawLine() {
                    var dotNum = 16,
                    //数字越大,参考线约密集
                    pos = util.getBallPos(_this.cueBall.elem);

                    $(_this.dotWrap).empty();
                    fromX = pos[0];
                    fromY = pos[1]; //fromX和fromY是母球的坐标
                    var partX = (toX - fromX) / dotNum,

                    partY = (toY - fromY) / dotNum;
                    for (var i = 1; i < dotNum; i++) {
                        var x = fromX + partX * i,
                        y = fromY + partY * i;
                        _this.drawDot(_this.dotWrap, x, y);
                    }
                }