Usermedia, loading snapshots into multiple sprites

Get help using Construct 2

Post » Thu Feb 27, 2014 12:03 pm

Based on the Webcam example in C2 I have a UserMedia object set up and when I press spacebar it snaps a picture from the webcam feed and loads into my sprite with Load image from URL(UserMedia.SnapshotURL). I want to add 3 more sprites where each time I press spacebar it loads the image from the webcam into the different sprites, say I have SnapshotSprite1,2,3 and 4, I press space then it takes a snapshot and puts it in 1, then I press space again it puts the current snapshot in 2, and so forth. I have tried adding additional sprite objects, but I cant figure out how to target the different sprites with the current snapshot, it just loads the same snapshot in each sprite when I press spacebar. Any help would be appreciated, thanks.
B
49
S
16
G
2
Posts: 110
Reputation: 4,359

Post » Sat Mar 15, 2014 6:07 pm

I'm having the same issue, so would really appreciate knowing the answer to this?

I've looked at the data URL and they are different with each snap, but each sprite instance just picks up the last snapshot (when using load image URL action on the sprite).
B
13
S
2
Posts: 27
Reputation: 1,899

Post » Sat Mar 15, 2014 9:09 pm

are you sure you are picking a different sprite when you use the load action?

system: pick nth instance, (choose objecttype) and set instance number (could be var snapshotcount)

so if the snapshot objects already exist

onclick,
pick
loadurl
add 1 to snapshotcount

other than that, its probably possible to use one instance, and first set frame and then load url

ps: you probably need to wait for loadurl is ready, but its thesame

onclick take snapshot
onready pick sprite, load url, add 1 to snapshotcount
ImageImage
B
70
S
21
G
7
Posts: 827
Reputation: 10,052

Post » Sat Mar 15, 2014 10:05 pm

I think the issue is that each sprite instance refers to an image (animation frame 0) that is replaced by the snapshot.

The only way I have managed to fix this is to preset the number of frames (snapshots) in to the default animation for the sprite and load each snapshot in to successive animation frames (as the snapshot is taken). This is OK, but I get the same problem once my animation frame index goes beyond the size (frames) of the default animation.

Is there a way of creating sprites with a new image (frame 0) to avoid this?
B
13
S
2
Posts: 27
Reputation: 1,899


Return to How do I....?

Who is online

Users browsing this forum: beohs, Elliott, Yahoo [Bot] and 12 guests