Some tests
This commit is contained in:
parent
e08c4b2bb3
commit
9abd6a4663
2 changed files with 36 additions and 16 deletions
|
@ -1,47 +1,67 @@
|
|||
(function() {
|
||||
var bubble = {};
|
||||
|
||||
var show = function(text, position) {
|
||||
return new Promise(function(resolve) {
|
||||
muri.get('mouse').disable();
|
||||
|
||||
var activeTalk = false;
|
||||
var skip = false;
|
||||
var dom = document.getElementById('bubble');
|
||||
|
||||
var show = function(text, position) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
dom.style.display = '';
|
||||
dom.style.left = position[0]*8;
|
||||
dom.style.top = position[1]*8;
|
||||
dom.innerHTML = '';
|
||||
|
||||
parts = text.split(' ');
|
||||
var show = function() {
|
||||
var showFragment = function() {
|
||||
if (skip) {
|
||||
dom.innerHTML = '';
|
||||
dom.style.display = 'none';
|
||||
skip = false;
|
||||
throw new Error('dfad');
|
||||
}
|
||||
if (parts.length === 0) {
|
||||
setTimeout(function() {
|
||||
muri.get('mouse').enable();
|
||||
dom.style.display = 'none';
|
||||
return resolve();
|
||||
}, 2000);
|
||||
}, 1500);
|
||||
return;
|
||||
}
|
||||
dom.innerHTML += parts.shift() + ' ';
|
||||
setTimeout(show, 150);
|
||||
setTimeout(showFragment, 150);
|
||||
};
|
||||
show();
|
||||
showFragment();
|
||||
});
|
||||
};
|
||||
|
||||
bubble.skip = function() {
|
||||
dom.innerHTML = '';
|
||||
skip = true;
|
||||
};
|
||||
|
||||
bubble.stop = function() {
|
||||
bubble.skip();
|
||||
if (!activeTalk) return;
|
||||
activeTalk.reject();
|
||||
activeTalk = false;
|
||||
};
|
||||
|
||||
bubble.talk = function(texts, position) {
|
||||
if (texts.length === 0) return;
|
||||
var text = texts.shift();
|
||||
return show(text, position || [5, 44]).then(function() {
|
||||
return bubble.talk(texts, position);
|
||||
});
|
||||
return show(text, position || [5, 44])
|
||||
.then(function() {return bubble.talk(texts, position);})
|
||||
.catch(function() { return; });
|
||||
};
|
||||
|
||||
bubble.story = function(talkList) {
|
||||
if (talkList.length === 0) return;
|
||||
var params = talkList.shift();
|
||||
return bubble.talk(params[0], params[1]).then(function() {
|
||||
return bubble.story(talkList);
|
||||
});
|
||||
var activeTalk = bubble.talk(params[0], params[1])
|
||||
.then(function() {return bubble.story(talkList);})
|
||||
.catch(function() { return; });
|
||||
|
||||
return activeTalk;
|
||||
};
|
||||
|
||||
bubble.name = 'bubble';
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
muri.get('entity')
|
||||
.create('stasis.lightSwitch',
|
||||
kontra.sprite({x: 16, y: 13, width: 3, height: 2,
|
||||
kontra.sprite({x: 15, y: 12, width: 3, height: 2,
|
||||
image: kontra.assets.images.stasis_lightSwitch}))
|
||||
.addCallback(function() {
|
||||
if (!roomState.isLightOn) {
|
||||
|
|
Loading…
Reference in a new issue