小编Jon*_*091的帖子

检测画布中的鼠标单击位置

我有一个真正的问题,试图定义一个函数,我点击空白区域.到目前为止,我已经设法定义了我点击一个对象的位置 - 其中有10个 - 但现在我需要一个单独的函数,以便在我不点击任何对象时.一般的想法可以在http://deciballs.co.uk/experience.html找到.对象是戒指.我的代码如下......任何想法?

var shapeObj = function (context, canvas, settingsBox, radius) {
    this.ctx = context;
    this.canvas = canvas;
    this.sBox = settingsBox;

    this.frequencies = new Array(220, 440, 1024, 2048);
    this.cols = new Array(255, 225, 200, 175, 150);
    this.strokes = new Array(1, 1.5, 2);
    this.waves = new Array('sine', 'sawtooth', 'triangle', 'square');

    this.properties = {
        dur: Math.random()*0.5,
        freq: this.frequencies[Math.floor(Math.random() * this.frequencies.length)],
        radius: radius,
        stroke: this.strokes[Math.floor(Math.random() * this.strokes.length)],
        speed: Math.random()*6-3,
        vol: Math.random()*10,
        col1: this.cols[Math.floor(Math.random() * this.cols.length)],
        col2: this.cols[Math.floor(Math.random() * this.cols.length)], …
Run Code Online (Sandbox Code Playgroud)

javascript mouse canvas function click

3
推荐指数
1
解决办法
3361
查看次数

标签 统计

canvas ×1

click ×1

function ×1

javascript ×1

mouse ×1