Skip to content

obj_bound()

Kevin110026 edited this page Mar 5, 2025 · 1 revision

new obj_bound(obj1, obj2, minr = null, maxr = null, k = 1000)

將動畫物件obj1和obj2的距離固定在範圍內

arg- k 讓obj1, obj2的距離恢復到範圍內的速度

範例程式
let n = 10;
let a = [];
for (let i = 0; i < n; i++) {
    a[i] = new pack_circle({ x: 100, y: 100 });
    for(let j=0; j<i; j++)
    {
        new obj_bound(a[i], a[j], 50, 100);
    }
}

黏在一團的球

Clone this wiki locally