mirror of
https://github.com/genxium/DelayNoMore
synced 2025-10-09 00:26:39 +00:00
Misc fixes for UI alignments.
This commit is contained in:
@@ -14,10 +14,6 @@ cc.Class({
|
||||
type: cc.Node,
|
||||
default: null
|
||||
},
|
||||
myAvatarNode: {
|
||||
type: cc.Node,
|
||||
default: null
|
||||
},
|
||||
exitBtnNode: {
|
||||
type: cc.Node,
|
||||
default: null
|
||||
@@ -25,8 +21,7 @@ cc.Class({
|
||||
},
|
||||
|
||||
// LIFE-CYCLE CALLBACKS:
|
||||
onLoad() {
|
||||
},
|
||||
onLoad() {},
|
||||
|
||||
init() {
|
||||
if (null != this.firstPlayerInfoNode) {
|
||||
@@ -70,29 +65,20 @@ cc.Class({
|
||||
const playerInfoNode = this.playersInfoNode[playerMeta.joinIndex];
|
||||
if (null == playerInfoNode) {
|
||||
cc.error("There's no playerInfoNode for joinIndex == ", joinIndex, ", as `this.playerInfoNode` is currently ", this.playersInfoNode);
|
||||
}
|
||||
}
|
||||
playerInfoNode.active = true;
|
||||
if (2 == playerMeta.joinIndex) {
|
||||
if (null != this.findingAnimNode) {
|
||||
if (null != this.findingAnimNode) {
|
||||
this.findingAnimNode.active = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//显示自己的头像名称以及他人的头像名称
|
||||
for (let i in playerMetas) {
|
||||
const playerMeta = playerMetas[i];
|
||||
console.log("Showing playerMeta:", playerMeta);
|
||||
const playerInfoNode = this.playersInfoNode[playerMeta.joinIndex];
|
||||
|
||||
(() => { //远程加载头像
|
||||
let remoteUrl = playerMeta.avatar;
|
||||
if (remoteUrl == null || remoteUrl == '') {
|
||||
cc.log(`No avatar to show for :`);
|
||||
cc.log(playerMeta);
|
||||
}
|
||||
})();
|
||||
|
||||
function isEmptyString(str) {
|
||||
return str == null || str == ''
|
||||
}
|
||||
|
@@ -68,7 +68,7 @@ cc.Class({
|
||||
// LIFE-CYCLE CALLBACKS:
|
||||
|
||||
onLoad() {
|
||||
cc.view.setOrientation(cc.macro.ORIENTATION_LANDSCAPE);
|
||||
cc.view.setOrientation(cc.macro.ORIENTATION_AUTO);
|
||||
cc.view.enableAutoFullScreen(true);
|
||||
|
||||
window.atFirstLocationHref = window.location.href.split('#')[0];
|
||||
|
@@ -476,7 +476,6 @@ cc.Class({
|
||||
console.log(`Received parsedBattleColliderInfo via ws`);
|
||||
// TODO: Upon reconnection, the backend might have already been sending down data that'd trigger "onRoomDownsyncFrame & onInputFrameDownsyncBatch", but frontend could reject those data due to "battleState != PlayerBattleState.ACTIVE".
|
||||
Object.assign(self, parsedBattleColliderInfo);
|
||||
self.tooFastDtIntervalMillis = 0.5 * self.rollbackEstimatedDtMillis;
|
||||
|
||||
const tiledMapIns = self.node.getComponent(cc.TiledMap);
|
||||
|
||||
@@ -911,12 +910,13 @@ batchInputFrameIdRange=[${batch[0].inputFrameId}, ${batch[batch.length - 1].inpu
|
||||
update(dt) {
|
||||
const self = this;
|
||||
if (ALL_BATTLE_STATES.IN_BATTLE == self.battleState) {
|
||||
const elapsedMillisSinceLastFrameIdTriggered = performance.now() - self.lastRenderFrameIdTriggeredAt;
|
||||
if (elapsedMillisSinceLastFrameIdTriggered < self.tooFastDtIntervalMillis) {
|
||||
// [WARNING] We should avoid a frontend ticking too fast to prevent cheating, as well as ticking too slow to cause a "resync avalanche" that impacts user experience!
|
||||
// console.debug("Avoiding too fast frame@renderFrameId=", self.renderFrameId, ": elapsedMillisSinceLastFrameIdTriggered=", elapsedMillisSinceLastFrameIdTriggered);
|
||||
//return;
|
||||
}
|
||||
/*
|
||||
[WARNING] Different devices might differ in the rate of calling "update(dt)", and the game engine is responsible of keeping this rate statistically constant.
|
||||
|
||||
Significantly different rates of calling "update(dt)" among players in a same battle would result in frequent [type#1 forceConfirmation], if you have any doubt on troubles caused by this, sample the FPS curve from all players in that battle.
|
||||
|
||||
Kindly note that Significantly different network bandwidths or delay fluctuations would result in frequent [type#1 forceConfirmation] too, but CAUSE FROM DIFFERENT LOCAL "update(dt)" RATE SHOULD BE THE FIRST TO INVESTIGATE AND ELIMINATE -- because we have control on it, but no one has control on the internet.
|
||||
*/
|
||||
try {
|
||||
let st = performance.now();
|
||||
const noDelayInputFrameId = gopkgs.ConvertToNoDelayInputFrameId(self.renderFrameId);
|
||||
|
@@ -11,14 +11,6 @@ cc.Class({
|
||||
type: cc.Object,
|
||||
default: null
|
||||
},
|
||||
myAvatarNode: {
|
||||
type: cc.Node,
|
||||
default: null,
|
||||
},
|
||||
myNameNode: {
|
||||
type: cc.Node,
|
||||
default: null,
|
||||
},
|
||||
rankingNodes: {
|
||||
type: [cc.Node],
|
||||
default: [],
|
||||
@@ -46,22 +38,6 @@ cc.Class({
|
||||
|
||||
showPlayerInfo(playerRichInfoDict) {
|
||||
this.showRanking(playerRichInfoDict);
|
||||
this.showMyAvatar();
|
||||
this.showMyName();
|
||||
},
|
||||
|
||||
showMyName() {
|
||||
const selfPlayerInfo = JSON.parse(cc.sys.localStorage.getItem('selfPlayer'));
|
||||
let name = 'No name';
|
||||
if (null == selfPlayerInfo.displayName || "" == selfPlayerInfo.displayName) {
|
||||
name = selfPlayerInfo.name;
|
||||
} else {
|
||||
name = selfPlayerInfo.displayName;
|
||||
}
|
||||
if (!this.myNameNode) return;
|
||||
const myNameNodeLabel = this.myNameNode.getComponent(cc.Label);
|
||||
if (!myNameNodeLabel || null == name) return;
|
||||
myNameNodeLabel.string = name;
|
||||
},
|
||||
|
||||
showRanking(playerRichInfoDict) {
|
||||
@@ -115,42 +91,6 @@ cc.Class({
|
||||
}
|
||||
},
|
||||
|
||||
showMyAvatar() {
|
||||
const self = this;
|
||||
const selfPlayerInfo = JSON.parse(cc.sys.localStorage.getItem('selfPlayer'));
|
||||
let remoteUrl = selfPlayerInfo.avatar;
|
||||
if (remoteUrl == null || remoteUrl == '') {
|
||||
cc.log(`No avatar to show for myself, check storage.`);
|
||||
return;
|
||||
} else {
|
||||
cc.loader.load({
|
||||
url: remoteUrl,
|
||||
type: 'jpg'
|
||||
}, function(err, texture) {
|
||||
if (err != null || texture == null) {
|
||||
console.log(err);
|
||||
} else {
|
||||
const sf = new cc.SpriteFrame();
|
||||
sf.setTexture(texture);
|
||||
self.myAvatarNode.getComponent(cc.Sprite).spriteFrame = sf;
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
showRibbon(winnerInfo, ribbonNode) {
|
||||
const selfPlayerInfo = JSON.parse(cc.sys.localStorage.getItem('selfPlayer'));
|
||||
const texture = (selfPlayerInfo.playerId == winnerInfo.id) ? "textures/resultPanel/WinRibbon" : "textures/resultPanel/loseRibbon";
|
||||
cc.loader.loadRes(texture, cc.SpriteFrame, function(err, spriteFrame) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
return;
|
||||
}
|
||||
ribbonNode.getComponent(cc.Sprite).spriteFrame = spriteFrame;
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
onClose(evt) {
|
||||
if (this.node.parent) {
|
||||
this.node.parent.removeChild(this.node);
|
||||
|
Reference in New Issue
Block a user