Emote animations start and stop correctly

This commit is contained in:
RebeccaStankus 2019-08-15 12:01:25 -07:00
parent 143c3e966c
commit 078ff223a4

View file

@ -24,21 +24,24 @@
// #region EMOTE_UTILITY // #region EMOTE_UTILITY
// See the note below about needing to end reactions before another one starts // REMOVE THIS WHEN ENGINE CAN HANDLE BLENDING
// This just takes care of all 3 of them at the same time function maybeEndOtherReactions(currentEmote) {
function maybeEndOtherReactions() { print("CURRENT EMOTE: ", currentEmote);
if (raiseHandPlaying) { if (raiseHandPlaying && "raiseHand" != currentEmote) {
print("ENDING RAISE HAND");
MyAvatar.endReaction("raiseHand"); MyAvatar.endReaction("raiseHand");
raiseHandPlaying = false; raiseHandPlaying = false;
} }
if (applaudPlaying) { if (pointPlaying && "point" != currentEmote) {
MyAvatar.endReaction("applaudPlaying"); print("ENDING POINT");
applaudPlaying = false; MyAvatar.endReaction("point");
}
if (pointPlaying) {
MyAvatar.endReaction("pointPlaying");
pointPlaying = false; pointPlaying = false;
} }
if (applaudPlaying && "applaud" != currentEmote) {
print("ENDING APPLAUD");
MyAvatar.endReaction("applaud");
applaudPlaying = false;
}
} }
@ -77,31 +80,57 @@ var raiseHandPlaying = false;
var applaudPlaying = false; var applaudPlaying = false;
var pointPlaying = false; var pointPlaying = false;
function onMessageFromEmoteAppBar(message) { function onMessageFromEmoteAppBar(message) {
console.log("MESSAGE From emote app bar: ", message); console.log("MESSAGE From emote app bar: ", JSON.stringify(message));
if (message.source !== EMOTE_APP_BAR_MESSAGE_SOURCE) { if (message.source !== EMOTE_APP_BAR_MESSAGE_SOURCE) {
return; return;
} }
switch (message.method) { switch (message.method) {
case "happyPressed": case "happyPressed":
maybeEndOtherReactions("positive");
MyAvatar.triggerReaction("positive"); MyAvatar.triggerReaction("positive");
break; break;
case "sadPressed": case "sadPressed":
maybeEndOtherReactions("negative");
MyAvatar.triggerReaction("negative"); MyAvatar.triggerReaction("negative");
break; break;
case "raiseHandPressed": case "raiseHandPressed":
maybeEndOtherReactions(); if (raiseHandPlaying) {
MyAvatar.endReaction("raiseHand");
raiseHandPlaying = false;
return;
}
maybeEndOtherReactions("raiseHand");
MyAvatar.beginReaction("raiseHand"); MyAvatar.beginReaction("raiseHand");
raiseHandPlaying = true; raiseHandPlaying = true;
// REMOVE THESE WHEN ENGINE CAN HANDLE BLENDING
pointPlaying = false;
applaudPlaying = false;
break; break;
case "applaudPressed": case "applaudPressed":
maybeEndOtherReactions(); if (applaudPlaying) {
MyAvatar.endReaction("applaud");
applaudPlaying = false;
return;
}
maybeEndOtherReactions("applaud");
MyAvatar.beginReaction("applaud"); MyAvatar.beginReaction("applaud");
applaudPlaying = true; applaudPlaying = true;
// REMOVE THESE WHEN ENGINE CAN HANDLE BLENDING
pointPlaying = false;
raiseHandPlaying = false;
break; break;
case "pointPressed": case "pointPressed":
maybeEndOtherReactions(); if (pointPlaying) {
MyAvatar.endReaction("point");
pointPlaying = false;
return;
}
maybeEndOtherReactions("point");
MyAvatar.beginReaction("point"); MyAvatar.beginReaction("point");
applaudPlaying = true; pointPlaying = true;
// REMOVE THESE WHEN ENGINE CAN HANDLE BLENDING
raiseHandPlaying = false;
applaudPlaying = false;
break; break;
case "toggleEmojiApp": case "toggleEmojiApp":
toggleEmojiApp(); toggleEmojiApp();