mirror of
https://github.com/genxium/DelayNoMore
synced 2025-10-09 00:26:39 +00:00
Fixed frontend action triggers.
This commit is contained in:
@@ -134,7 +134,7 @@ cc.Class({
|
||||
previousSelfInput = (null == previousInputFrameDownsync ? null : previousInputFrameDownsync.InputList[joinIndex - 1]);
|
||||
if (null != existingInputFrame) {
|
||||
// This could happen upon either [type#1] or [type#2] forceConfirmation, where "refRenderFrame" is accompanied by some "inputFrameDownsyncs". The check here also guarantees that we don't override history
|
||||
console.log(`noDelayInputFrameId=${inputFrameId} already exists in recentInputCache: recentInputCache=${self._stringifyRecentInputCache(false)}`);
|
||||
//console.log(`noDelayInputFrameId=${inputFrameId} already exists in recentInputCache: recentInputCache=${self._stringifyRecentInputCache(false)}`);
|
||||
return [previousSelfInput, existingInputFrame.InputList[joinIndex - 1]];
|
||||
}
|
||||
|
||||
@@ -152,6 +152,7 @@ cc.Class({
|
||||
prefabbedInputList[k] = (prefabbedInputList[k] & 15);
|
||||
}
|
||||
currSelfInput = self.ctrl.getEncodedInput(); // When "null == existingInputFrame", it'd be safe to say that the realtime "self.ctrl.getEncodedInput()" is for the requested "inputFrameId"
|
||||
//console.log(`@rdf.Id=${self.renderFrameId}, currSelfInput=${currSelfInput}`);
|
||||
prefabbedInputList[(joinIndex - 1)] = currSelfInput;
|
||||
while (self.recentInputCache.EdFrameId <= inputFrameId) {
|
||||
// Fill the gap
|
||||
@@ -916,12 +917,8 @@ batchInputFrameIdRange=[${batch[0].inputFrameId}, ${batch[batch.length - 1].inpu
|
||||
}
|
||||
try {
|
||||
let st = performance.now();
|
||||
let prevSelfInput = null,
|
||||
currSelfInput = null;
|
||||
const noDelayInputFrameId = gopkgs.ConvertToNoDelayInputFrameId(self.renderFrameId);
|
||||
if (gopkgs.ShouldGenerateInputFrameUpsync(self.renderFrameId)) {
|
||||
[prevSelfInput, currSelfInput] = self.getOrPrefabInputFrameUpsync(noDelayInputFrameId);
|
||||
}
|
||||
const [prevSelfInput, currSelfInput] = self.getOrPrefabInputFrameUpsync(noDelayInputFrameId);
|
||||
|
||||
let t0 = performance.now();
|
||||
if (self.shouldSendInputFrameUpsyncBatch(prevSelfInput, currSelfInput, self.lastUpsyncInputFrameId, noDelayInputFrameId)) {
|
||||
|
@@ -94,7 +94,7 @@ cc.Class({
|
||||
const p2Vpos = gopkgs.WorldToVirtualGridPos(boundaryObjs.playerStartingPositions[1].x, boundaryObjs.playerStartingPositions[1].y);
|
||||
const colliderRadiusV = gopkgs.WorldToVirtualGridPos(12.0, 0);
|
||||
|
||||
const speciesIdList = [1, 4096];
|
||||
const speciesIdList = [4096, 1];
|
||||
const chConfigsOrderedByJoinIndex = gopkgs.GetCharacterConfigsOrderedByJoinIndex(speciesIdList);
|
||||
|
||||
const startRdf = window.pb.protos.RoomDownsyncFrame.create({
|
||||
|
@@ -108,7 +108,9 @@ cc.Class({
|
||||
this.cachedBtnRightLevel = 0;
|
||||
|
||||
this.cachedBtnALevel = 0;
|
||||
this.btnAEdgeTriggerLock = false;
|
||||
this.cachedBtnBLevel = 0;
|
||||
this.btnBEdgeTriggerLock = false;
|
||||
|
||||
this.canvasNode = this.mapNode.parent;
|
||||
this.mainCameraNode = this.canvasNode.getChildByName("Main Camera"); // Cannot drag and assign the `mainCameraNode` from CocosCreator EDITOR directly, otherwise it'll cause an infinite loading time, till v2.1.0.
|
||||
@@ -164,30 +166,30 @@ cc.Class({
|
||||
|
||||
if (self.btnA) {
|
||||
self.btnA.on(cc.Node.EventType.TOUCH_START, function(evt) {
|
||||
self.cachedBtnALevel = 1;
|
||||
self._triggerEdgeBtnA(true);
|
||||
evt.target.runAction(cc.scaleTo(0.1, 0.3));
|
||||
});
|
||||
self.btnA.on(cc.Node.EventType.TOUCH_END, function(evt) {
|
||||
//self.cachedBtnALevel = 0;
|
||||
self._triggerEdgeBtnA(false);
|
||||
evt.target.runAction(cc.scaleTo(0.1, 1.0));
|
||||
});
|
||||
self.btnA.on(cc.Node.EventType.TOUCH_CANCEL, function(evt) {
|
||||
//self.cachedBtnALevel = 0;
|
||||
self._triggerEdgeBtnA(false);
|
||||
evt.target.runAction(cc.scaleTo(0.1, 1.0));
|
||||
});
|
||||
}
|
||||
|
||||
if (self.btnB) {
|
||||
self.btnB.on(cc.Node.EventType.TOUCH_START, function(evt) {
|
||||
self.cachedBtnBLevel = 1;
|
||||
self._triggerEdgeBtnB(true);
|
||||
evt.target.runAction(cc.scaleTo(0.1, 0.3));
|
||||
});
|
||||
self.btnB.on(cc.Node.EventType.TOUCH_END, function(evt) {
|
||||
//self.cachedBtnBLevel = 0;
|
||||
self._triggerEdgeBtnB(false);
|
||||
evt.target.runAction(cc.scaleTo(0.1, 1.0));
|
||||
});
|
||||
self.btnB.on(cc.Node.EventType.TOUCH_CANCEL, function(evt) {
|
||||
//self.cachedBtnBLevel = 0;
|
||||
self._triggerEdgeBtnB(false);
|
||||
evt.target.runAction(cc.scaleTo(0.1, 1.0));
|
||||
});
|
||||
}
|
||||
@@ -224,10 +226,10 @@ cc.Class({
|
||||
self.cachedBtnRightLevel = 1;
|
||||
break;
|
||||
case cc.macro.KEY.h:
|
||||
self.cachedBtnALevel = 1;
|
||||
self._triggerEdgeBtnA(true);
|
||||
break;
|
||||
case cc.macro.KEY.j:
|
||||
self.cachedBtnBLevel = 1;
|
||||
self._triggerEdgeBtnB(true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -248,14 +250,12 @@ cc.Class({
|
||||
case cc.macro.KEY.d:
|
||||
self.cachedBtnRightLevel = 0;
|
||||
break;
|
||||
/*
|
||||
case cc.macro.KEY.h:
|
||||
self.cachedBtnALevel = 0;
|
||||
self._triggerEdgeBtnA(false);
|
||||
break;
|
||||
case cc.macro.KEY.j:
|
||||
self.cachedBtnBLevel = 0;
|
||||
self._triggerEdgeBtnB(false);
|
||||
break;
|
||||
*/
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -468,8 +468,8 @@ cc.Class({
|
||||
const btnALevel = (this.cachedBtnALevel << 4);
|
||||
const btnBLevel = (this.cachedBtnBLevel << 5);
|
||||
|
||||
this.cachedBtnALevel = 0;
|
||||
this.cachedBtnBLevel = 0;
|
||||
this.btnAEdgeTriggerLock = false;
|
||||
this.btnBEdgeTriggerLock = false;
|
||||
return (btnBLevel + btnALevel + discretizedDir);
|
||||
},
|
||||
|
||||
@@ -488,4 +488,18 @@ cc.Class({
|
||||
btnBLevel: btnBLevel,
|
||||
});
|
||||
},
|
||||
|
||||
_triggerEdgeBtnA(rising) {
|
||||
if (!this.btnAEdgeTriggerLock && (rising ? 0 : 1) == this.cachedBtnALevel) {
|
||||
this.cachedBtnALevel = (rising ? 1 : 0);
|
||||
this.btnAEdgeTriggerLock = true;
|
||||
}
|
||||
},
|
||||
|
||||
_triggerEdgeBtnB(rising) {
|
||||
if (!this.btnBEdgeTriggerLock && (rising ? 0 : 1) == this.cachedBtnBLevel) {
|
||||
this.cachedBtnBLevel = (rising ? 1 : 0);
|
||||
this.btnBEdgeTriggerLock = true;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
Reference in New Issue
Block a user