mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
81ef11163d | ||
![]() |
fcc19a6dcf | ||
![]() |
bcad2d5667 | ||
![]() |
3c83e5d24a |
@@ -719,10 +719,6 @@ namespace gdjs {
|
||||
this.createBody();
|
||||
}
|
||||
|
||||
// Reset contacts that happened this frame
|
||||
this.contactsStartedThisFrame.length = 0;
|
||||
this.contactsEndedThisFrame.length = 0;
|
||||
|
||||
// Step the world if not done this frame yet
|
||||
if (!this._sharedData.stepped) {
|
||||
this._sharedData.step(
|
||||
@@ -760,6 +756,10 @@ namespace gdjs {
|
||||
doStepPostEvents(runtimeScene) {
|
||||
this._updateBodyFromObject();
|
||||
|
||||
// Reset contacts that happened this frame
|
||||
this.contactsStartedThisFrame.length = 0;
|
||||
this.contactsEndedThisFrame.length = 0;
|
||||
|
||||
// Reset world step to update next frame
|
||||
this._sharedData.stepped = false;
|
||||
}
|
||||
|
@@ -131,8 +131,8 @@ describe('Physics2RuntimeBehavior', () => {
|
||||
|
||||
let hasBounced = false;
|
||||
let stepIndex = 0;
|
||||
while (stepIndex < 10 && !hasBounced) {
|
||||
runtimeScene.renderAndStep(1000 / fps);
|
||||
|
||||
runtimeScene.setEventsFunction(() => {
|
||||
if (movingObjectBehavior.getLinearVelocityY() > 0) {
|
||||
// If the moving object has a positive velocity, it hasn't bounced
|
||||
// on the static object
|
||||
@@ -150,9 +150,12 @@ describe('Physics2RuntimeBehavior', () => {
|
||||
stopped: true,
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
while (stepIndex < 10 && !hasBounced) {
|
||||
runtimeScene.renderAndStep(1000 / fps);
|
||||
stepIndex++;
|
||||
}
|
||||
|
||||
if (!hasBounced) {
|
||||
throw new Error('Contact did not happen, nothing was tested.');
|
||||
}
|
||||
@@ -176,10 +179,10 @@ describe('Physics2RuntimeBehavior', () => {
|
||||
}
|
||||
movingObjectBehavior.setLinearVelocityY(40000);
|
||||
|
||||
let hasBounced = false;
|
||||
let hasBegunBouncing = false;
|
||||
let stepIndex = 0;
|
||||
while (stepIndex < 10 && !hasBounced) {
|
||||
runtimeScene.renderAndStep(1000 / fps);
|
||||
|
||||
runtimeScene.setEventsFunction(() => {
|
||||
if (movingObjectBehavior.getLinearVelocityY() > 0) {
|
||||
// If the moving object has a positive velocity, it hasn't bounced
|
||||
// on the static object
|
||||
@@ -189,7 +192,8 @@ describe('Physics2RuntimeBehavior', () => {
|
||||
stopped: false,
|
||||
});
|
||||
} else {
|
||||
hasBounced = true;
|
||||
hasBegunBouncing = true;
|
||||
// At first frame, collision should have only started
|
||||
expect(movingObject.getY() < staticObject.getY()).to.be(true);
|
||||
assertCollision(movingObject, staticObject, {
|
||||
started: true,
|
||||
@@ -197,21 +201,36 @@ describe('Physics2RuntimeBehavior', () => {
|
||||
stopped: false,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
while (stepIndex < 10 && !hasBegunBouncing) {
|
||||
runtimeScene.renderAndStep(1000 / fps);
|
||||
stepIndex++;
|
||||
}
|
||||
if (!hasBounced) {
|
||||
throw new Error('Contact did not happen, nothing was tested.');
|
||||
|
||||
if (!hasBegunBouncing) {
|
||||
throw new Error(
|
||||
'Start of contact was not detected, nothing was tested.'
|
||||
);
|
||||
}
|
||||
|
||||
// At next frame, end of collision should be detected
|
||||
let hasFinishedBouncing = false;
|
||||
|
||||
runtimeScene.setEventsFunction(() => {
|
||||
hasFinishedBouncing = true;
|
||||
assertCollision(movingObject, staticObject, {
|
||||
started: false,
|
||||
collision: false,
|
||||
stopped: true,
|
||||
});
|
||||
});
|
||||
|
||||
runtimeScene.renderAndStep(1000 / fps);
|
||||
|
||||
// At next frame, end of collision should be detected
|
||||
assertCollision(movingObject, staticObject, {
|
||||
started: false,
|
||||
collision: false,
|
||||
stopped: true,
|
||||
});
|
||||
if (!hasFinishedBouncing) {
|
||||
throw new Error('End of contact was not detected, nothing was tested.');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
@@ -664,7 +664,21 @@ namespace gdjs {
|
||||
}
|
||||
const baseUrl = 'https://api.gdevelop-app.com/analytics';
|
||||
this._playerId = this._makePlayerUuid();
|
||||
let lastSessionHitTime = Date.now();
|
||||
/**
|
||||
* The duration that is already sent to the service
|
||||
* (in milliseconds).
|
||||
**/
|
||||
let sentDuration = 0;
|
||||
/**
|
||||
* The duration that is not yet sent to the service to avoid flooding
|
||||
* (in milliseconds).
|
||||
**/
|
||||
let notYetSentDuration = 0;
|
||||
/**
|
||||
* The last time when duration has been counted
|
||||
* either in sendedDuration or notYetSentDuration.
|
||||
**/
|
||||
let lastSessionResumeTime = Date.now();
|
||||
fetch(baseUrl + '/session', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
@@ -715,24 +729,39 @@ namespace gdjs {
|
||||
return;
|
||||
}
|
||||
|
||||
const now = Date.now();
|
||||
notYetSentDuration += now - lastSessionResumeTime;
|
||||
lastSessionResumeTime = now;
|
||||
|
||||
// Group repeated calls to sendSessionHit - which could
|
||||
// happen because of multiple event listeners being fired.
|
||||
if (Date.now() - lastSessionHitTime < 3 * 1000) {
|
||||
if (notYetSentDuration < 5 * 1000) {
|
||||
return;
|
||||
}
|
||||
lastSessionHitTime = Date.now();
|
||||
// The backend use seconds for duration.
|
||||
// The milliseconds will stay in notYetSentDuration.
|
||||
const toBeSentDuration = Math.floor(notYetSentDuration / 1000) * 1000;
|
||||
sentDuration += toBeSentDuration;
|
||||
notYetSentDuration -= toBeSentDuration;
|
||||
|
||||
navigator.sendBeacon(
|
||||
baseUrl + '/session-hit',
|
||||
JSON.stringify({
|
||||
gameId: this._data.properties.projectUuid,
|
||||
playerId: this._playerId,
|
||||
sessionId: this._sessionId,
|
||||
duration: Math.floor(sentDuration / 1000),
|
||||
})
|
||||
);
|
||||
};
|
||||
if (typeof navigator !== 'undefined' && typeof document !== 'undefined') {
|
||||
document.addEventListener('visibilitychange', () => {
|
||||
sendSessionHit();
|
||||
if (document.visibilityState === 'visible') {
|
||||
// Skip the duration the game was hidden.
|
||||
lastSessionResumeTime = Date.now();
|
||||
} else {
|
||||
sendSessionHit();
|
||||
}
|
||||
});
|
||||
window.addEventListener(
|
||||
'pagehide',
|
||||
|
@@ -41,7 +41,7 @@ module.exports = [
|
||||
"languageCode": "cs_CZ",
|
||||
"languageName": "Czech",
|
||||
"languageNativeName": "čeština",
|
||||
"translationRatio": 0.14570195818121479
|
||||
"translationRatio": 0.1495187520743445
|
||||
},
|
||||
{
|
||||
"languageCode": "da_DK",
|
||||
@@ -77,7 +77,7 @@ module.exports = [
|
||||
"languageCode": "es_ES",
|
||||
"languageName": "Spanish",
|
||||
"languageNativeName": "Español",
|
||||
"translationRatio": 0.985894457351477
|
||||
"translationRatio": 0.9878858280783273
|
||||
},
|
||||
{
|
||||
"languageCode": "fa_IR",
|
||||
@@ -131,7 +131,7 @@ module.exports = [
|
||||
"languageCode": "id_ID",
|
||||
"languageName": "Indonesian",
|
||||
"languageNativeName": "Bahasa Indonesia",
|
||||
"translationRatio": 0.5386657816130103
|
||||
"translationRatio": 0.5393295718552937
|
||||
},
|
||||
{
|
||||
"languageCode": "ig_NG",
|
||||
@@ -149,7 +149,7 @@ module.exports = [
|
||||
"languageCode": "ja_JP",
|
||||
"languageName": "Japanese",
|
||||
"languageNativeName": "日本語",
|
||||
"translationRatio": 0.9774311317623631
|
||||
"translationRatio": 0.9797543976103551
|
||||
},
|
||||
{
|
||||
"languageCode": "ka_GE",
|
||||
@@ -227,7 +227,7 @@ module.exports = [
|
||||
"languageCode": "pt_BR",
|
||||
"languageName": "Brazilian Portuguese",
|
||||
"languageNativeName": "Português brasileiro",
|
||||
"translationRatio": 0.9535346830401593
|
||||
"translationRatio": 0.9624958513109857
|
||||
},
|
||||
{
|
||||
"languageCode": "pt_PT",
|
||||
@@ -263,7 +263,7 @@ module.exports = [
|
||||
"languageCode": "sl_SI",
|
||||
"languageName": "Slovene",
|
||||
"languageNativeName": "slovenski jezik",
|
||||
"translationRatio": 0.9910388317291736
|
||||
"translationRatio": 0.9933620975771656
|
||||
},
|
||||
{
|
||||
"languageCode": "sq_AL",
|
||||
@@ -305,7 +305,7 @@ module.exports = [
|
||||
"languageCode": "uk_UA",
|
||||
"languageName": "Ukrainian",
|
||||
"languageNativeName": "Українська",
|
||||
"translationRatio": 0.8647527381347494
|
||||
"translationRatio": 0.868901427149021
|
||||
},
|
||||
{
|
||||
"languageCode": "ur_PK",
|
||||
@@ -323,7 +323,7 @@ module.exports = [
|
||||
"languageCode": "vi_VN",
|
||||
"languageName": "Vietnamese",
|
||||
"languageNativeName": "Tiếng Việt",
|
||||
"translationRatio": 0.05426485230667111
|
||||
"translationRatio": 0.05741785595751747
|
||||
},
|
||||
{
|
||||
"languageCode": "yo_NG",
|
||||
@@ -335,7 +335,7 @@ module.exports = [
|
||||
"languageCode": "zh_CN",
|
||||
"languageName": "Chinese Simplified",
|
||||
"languageNativeName": "简化字",
|
||||
"translationRatio": 0.9918685695320278
|
||||
"translationRatio": 0.9925323597743113
|
||||
},
|
||||
{
|
||||
"languageCode": "zh_TW",
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -2,7 +2,7 @@
|
||||
"name": "gdevelop",
|
||||
"productName": "GDevelop 5",
|
||||
"description": "GDevelop 5 IDE - the open-source, cross-platform game engine designed for everyone",
|
||||
"version": "5.0.137",
|
||||
"version": "5.0.138",
|
||||
"author": "GDevelop Team <hello@gdevelop.io>",
|
||||
"license": "MIT",
|
||||
"homepage": "https://gdevelop.io",
|
||||
|
Reference in New Issue
Block a user