Skip to content

Commit

Permalink
fix: Disable game for mobile devices
Browse files Browse the repository at this point in the history
Redeploy PDF
  • Loading branch information
201flaviosilva committed Jun 5, 2024
1 parent 28d90fe commit f34c190
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 21 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/GithubPagesDeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ on:
branches:
- master
- "V2-Phaser-Game"
- "PDF"
pull_request:
branches:
- master
- "V2-Phaser-Game"
- "PDF"

jobs:
build:
Expand All @@ -33,6 +35,15 @@ jobs:
- name: Build # Output build files in `dist` folder
run: npm run build

# ------- PDF --------
- name: Checkout the `PDF` branch
uses: actions/checkout@v2
with:
ref: PDF
# Put the checked out files inside the `dist/PDF` folder
path: dist/PDF
clean: false

# ------- gh-pages (deploy) --------
- name: Deploy in gh-pages
uses: JamesIves/github-pages-deploy-action@4.1.1
Expand Down
53 changes: 32 additions & 21 deletions src/Scenes/Index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,16 @@ import { TextStyle } from "../Theme";
export default class Index extends Phaser.Scene {
constructor() {
super({ key: "Index" });
this.isMobile = false;
}

init() {
const { android, iOS, iPad, iPhone, windowsPhone } = this.sys.game.device.os;
if (android || iOS || iPad || iPhone || windowsPhone) {
DOM.notification({
text: "This game not available on mobile devices. Please click on Vetus button.",
animated: true,
animationTime: 10,
closeButton: true,
endPosition: 100,
style: {
border: "1px solid #058005",
boxShadow: "0 0 10px #058005, 0 0 50px #058005",
background: "#023b02",
},
textStyle: {
color: "#058005",
boxShadow: "0 0 10px #023b02, 0 0 50px #023b02",
},
});
}
this.isMobile = android || iOS || iPad || iPhone || windowsPhone;

if (this.isMobile)
this.pushNotification("This game is currently not available on mobile devices. Please click on PDF button.");

}

create() {
Expand All @@ -37,14 +25,18 @@ export default class Index extends Phaser.Scene {
const margin = 36;

// Background
const background = new StarsBackground(this);
const _background = new StarsBackground(this);

// Start
this.createText({
x: middleWidth,
y: middleHeight - margin,
text: "Start",
action: () => this.scene.start("Start"),
action: () => {
this.isMobile ?
this.pushNotification("Sorry, the current version of the game do not work on mobile :/") :
this.scene.start("Start");
},
});

// PDF
Expand All @@ -57,7 +49,7 @@ export default class Index extends Phaser.Scene {
}

openPDF() {
const url = "https://github.com/201flaviosilva/201flaviosilva.github.io/releases?q=PDF&expanded=true";
const url = "./PDF/index.html";
const s = window.open(url, "_blank");

if (s && s.focus) s.focus();
Expand All @@ -71,4 +63,23 @@ export default class Index extends Phaser.Scene {
label.on("pointerout", () => label.setStyle(TextStyle.home.menu.normal));
label.on("pointerup", action);
}

pushNotification(text) {
DOM.notification({
text,
animated: true,
animationTime: 5,
closeButton: true,
endPosition: 100,
style: {
border: "1px solid #00dd00",
boxShadow: "0 0 10px #058005, 0 0 50px #058005",
background: "#023b02",
},
textStyle: {
color: "#ff0000",
boxShadow: "0 0 10px #023b02, 0 0 50px #023b02",
},
});
}
}

0 comments on commit f34c190

Please sign in to comment.