Hi, i did a thing (Multitouch Snap!)

that's hopefully a problem with regular Snap! or it's the fact that on iOS the pointers get freed after 4 seconds.

i'll go check. also you may want to update morphic.js in the same folder with this. because i've been updating it a whole lot.

also hard reload, because the service worker.

I put the stuff there and it is still not working

the block is supposed to return a list that has other lists in it each list is supposed to contain 2 things X and Y of each finger and if there isn’t a finger then no list

well the list is given by world.hands and to create a list like the ones you see in snap you need to use new List(js array goes here or a variable that references one)

Could we get all of the worlds hands positions? Somehow (me brainstorming) if world.hands returns a list we can get each hand like if we did for each item in world.hands we would get the item/HandMorph and then get its position and add that to a list and then we return the list when done? Is my idea good?

Do you think it would work?

bud, i made the thing, and yes that works. however the size of the list will change.

if it's zero, that's bad. and that means something went horribly wrong.

Yeah and for getMousePosition it returns nothing. I looked in the console and I saw no errors

what do you mean by getMousePosition the hand IS a morph, you use hand.position() to get the position of the pointer.

No this

Process.prototype.reportMousePosition = function () {
var world, pos;
if (this.homeContext.receiver) {
world = this.homeContext.receiver.world();
if (world) {
if (world.hands.length === 1) {
pos = this.homeContext.receiver.snapPoint(world.hand.position());
return new List([pos.x, pos.y]);
} else {
var result = ;
for (let i = 0; i < world.hands.length; i++) {
const hand = world.hands[i];
let point = this.homeContext.receiver.snapPoint(hand.position());
result.push(new List([point.x, point.y]));
}
return new List(result);
}
}
}
return '';
};

you could just run it as a javascript function in snap. or add another js file paste that in there. and include it in the snap.html file.

No I meant by getmouseposiiton was the function you gave me it wasn’t working the function I gave you was returning nothing and the other ones were returning zero

So when a hand is created for that finger alone just report the position of that hand and store it in a list and if there is another add another list. Could you make a function for that?

i honestly thought that just worked.

fixing.

Ok!

this should work

Process.prototype.reportMousePosition = function () {
    var world, pos;
    if (this.homeContext.receiver) {
        world = this.homeContext.receiver.world();
        if (world) {
            if (world.hands.length < 2) {
                pos = this.homeContext.receiver.snapPoint(world.hand.position());
                return new List([pos.x, pos.y]);
            } else {
                var result = [];
                for (let i = 0; i < world.hands.length; i++) {
                    const hand = world.hands[i];
                    let point = this.homeContext.receiver.snapPoint(hand.position());
                    result.push(new List([point.x, point.y]));
                }
                return new List(result);
            }
        }
    }
    return '';
};

Process.prototype.reportMouseX = function () {
    var world;
    if (this.homeContext.receiver) {
        world = this.homeContext.receiver.world();
        if (world) {
            if (world.hands.length < 2) {
                return this.homeContext.receiver.snapPoint(world.hand.position()).x;
            } else {
                return new List(world.hands.map((hand) => this.homeContext.receiver.snapPoint(hand.position()).x));
            }
        }
    }
    return 0;
};

Process.prototype.reportMouseY = function () {
    var world;
    if (this.homeContext.receiver) {
        world = this.homeContext.receiver.world();
        if (world) {
            if (world.hands.length < 2) {
                return this.homeContext.receiver.snapPoint(world.hand.position()).y;
            } else {
                return new List(world.hands.map((hand) => this.homeContext.receiver.snapPoint(hand.position()).y));
            }
        }
    }
    return 0;
};

i think you're using regular Snap! source, the "Source Code" button on the site isn't the one you want this is.

Nah I switched my morphic.js file to yours

still might be wise to download my source for snap. ignore the upper directory. just a random thing i did awhile back.

Ok I’ll try it then add my block

It’s still not working see