capital letter all & samll letter upto m complete
This commit is contained in:
351
src/pages/capital-letter/A.astro
Normal file
351
src/pages/capital-letter/A.astro
Normal file
@@ -0,0 +1,351 @@
|
||||
---
|
||||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script is:inline>
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
width: isMobile ? window.innerWidth : window.innerWidth / 2,
|
||||
height: window.innerHeight / 2,
|
||||
};
|
||||
|
||||
const config = {
|
||||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
},
|
||||
scene: {
|
||||
preload: preload,
|
||||
create: create,
|
||||
update: update
|
||||
}
|
||||
};
|
||||
// backgroundImage.png
|
||||
const game = new Phaser.Game(config);
|
||||
const customWidth = window.innerWidth;
|
||||
const customHeight = window.innerHeight;
|
||||
let firstLayer, secondLayer, thirdLayer;
|
||||
let graphics;
|
||||
let isDrawing = false;
|
||||
// let x = 100;
|
||||
|
||||
// // Use x
|
||||
// console.log(x);
|
||||
|
||||
if(isMobile){
|
||||
cloudeSize = 200;
|
||||
cloudHeight = 340;
|
||||
canvasScale = 0.14
|
||||
canvasHeight = 35;
|
||||
letterHeight = 70;
|
||||
letterScale = 1;
|
||||
backgroundScale = 0.8;
|
||||
sunScale = 0.1;
|
||||
sunScalePlus = 0.15;
|
||||
sunWidth = 70;
|
||||
sunHeight = 70;
|
||||
beanieScale = 0.35;
|
||||
beanieScalePlus = 0.365;
|
||||
beanieWidth = 135;
|
||||
beanieHeight = 170;
|
||||
animatedAHeight = 35;
|
||||
animatedAScale = 0.65;
|
||||
} else{
|
||||
cloudeSize = 500;
|
||||
cloudHeight = 250;
|
||||
canvasScale = 0.195;
|
||||
canvasHeight = 20;
|
||||
letterHeight = 50;
|
||||
letterScale = 1;
|
||||
backgroundScale = 1;
|
||||
sunScale = 0.2;
|
||||
sunScalePlus = 0.25;
|
||||
sunWidth = 200;
|
||||
sunHeight = 100;
|
||||
beanieScale = 0.4;
|
||||
beanieScalePlus = 0.45;
|
||||
beanieWidth = 200;
|
||||
beanieHeight = 255;
|
||||
animatedAHeight = 20;
|
||||
animatedAScale = 0.73;
|
||||
}
|
||||
function preload() {
|
||||
this.load.video('animatedA', '/assets/animated-letter/capital_a.mp4');
|
||||
this.load.svg('letterA', '/assets/capital-letter/a.svg');
|
||||
this.load.svg('layer1', '/assets/capital-letter/a_l1.svg');
|
||||
this.load.svg('layer2', '/assets/capital-letter/a_l2.svg');
|
||||
this.load.svg('layer3', '/assets/capital-letter/a_l3.svg');
|
||||
this.load.audio('audioOne', '/assets/audio/slant-left.mp3');
|
||||
this.load.audio('audioTwo', '/assets/audio/slant-right.mp3');
|
||||
this.load.audio('audioThree', '/assets/audio/slide.mp3');
|
||||
this.load.image('topLogo', '/assets/top_logo.png');
|
||||
this.load.svg('succesImage', '/assets/svg/tick.svg');
|
||||
this.load.svg('hintImage', '/assets/svg/hint.svg');
|
||||
this.load.svg('handPointer', '/assets/svg/hand.svg');
|
||||
this.load.image('backgroundImage', '/assets/bg6.png');
|
||||
this.load.image('cloud', '/assets/cloud.png');
|
||||
this.load.image('canvas', '/assets/canvas4.png');
|
||||
// this.load.image('beanie', '/assets/beanie.png');
|
||||
this.load.image('beanie', '/assets/beanieImage.png');
|
||||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
}
|
||||
|
||||
function create() {
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : A", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
const sun = this.add.sprite(customWidth - sunWidth, sunHeight, 'sun').setScale(sunScale).setDepth(-1.9);
|
||||
const beanie = this.add.sprite(customWidth / 2 - beanieWidth, customHeight / 2 - beanieHeight, 'beanie').setScale(beanieScale).setDepth(1.9);
|
||||
|
||||
|
||||
const scaleFactor = sunScalePlus; // Scale factor (2 means double the size)
|
||||
const duration = 3000; // Duration of the animation in milliseconds
|
||||
|
||||
// Create a scaling tween
|
||||
this.tweens.add({
|
||||
targets: sun,
|
||||
scaleX: scaleFactor,
|
||||
scaleY: scaleFactor,
|
||||
duration: duration,
|
||||
ease: 'Linear',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const beaniescaleFactor = beanieScalePlus; // Scale factor (2 means double the size)
|
||||
const beanieduration = 2500;
|
||||
this.tweens.add({
|
||||
targets: beanie,
|
||||
scaleX: beaniescaleFactor + 0.004,
|
||||
scaleY: beaniescaleFactor,
|
||||
duration: beanieduration,
|
||||
ease: 'Redial',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const backgroundImages = this.add.image(customWidth / 2, customHeight /2, 'backgroundImage').setDepth(-2).setScale(backgroundScale);
|
||||
this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'letterA').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'letterA').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'animatedA').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
maskGraphics.fillRect(customWidth / 2 - (canvas.width * canvasScale) / 2, customHeight / 2 + canvasHeight - (canvas.height * canvasScale) / 2, canvas.width * canvasScale, canvas.height * canvasScale);
|
||||
const mask = maskGraphics.createGeometryMask();
|
||||
|
||||
|
||||
|
||||
let hideButton = this.add.text(customWidth / 2 - 65, customHeight / 1.1, "Let`s Do", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(customWidth / 2 - 50, customHeight / 1.1, "Help!", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 20;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : A', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
const animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedAHeight, 'animatedA').setDepth(2).setScale(animatedAScale);
|
||||
|
||||
// Play the video
|
||||
animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
||||
// You can set additional properties for the video, such as loop and mute:
|
||||
animatedLetter.setLoop(true); // Loop the video
|
||||
animatedLetter.setMute(false); // Unmute the video
|
||||
animatedLetter.on('complete', function () {
|
||||
// add function after end video;
|
||||
});
|
||||
|
||||
let textX, textY;
|
||||
|
||||
firstLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Slant Left',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
firstLayer.setAlpha(0.5);
|
||||
firstLayer.setInteractive({ draggable: true });
|
||||
|
||||
secondLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer2').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
const secondTextLayer = this.add.text(textX, textY, '2. Slant Right',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioTwoAudio = this.sound.add('audioTwo');
|
||||
secondTextLayer.setVisible(false);
|
||||
secondLayer.setDepth(1);
|
||||
secondLayer.setAlpha(0.5);
|
||||
secondLayer.setInteractive({ draggable: true });
|
||||
secondLayer.setVisible(false);
|
||||
|
||||
thirdLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer3').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 3 : customWidth * 0.75;
|
||||
const thirdTextLayer = this.add.text(textX, textY, '3. Slide', { font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioThreeAudio = this.sound.add('audioThree');
|
||||
thirdTextLayer.setVisible(false);
|
||||
thirdLayer.setDepth(1.1);
|
||||
// thirdLayer.setScale(1.15);
|
||||
thirdLayer.setAlpha(0.5);
|
||||
thirdLayer.setInteractive({ draggable: true });
|
||||
thirdLayer.setVisible(false);
|
||||
|
||||
// Add these variables to keep track of start points
|
||||
let firstDragStartPoint = { x: 0, y: 0 };
|
||||
let secondDragStartPoint = { x: 0, y: 0 };
|
||||
let thirdDragStartPoint = { x: 0, y: 0 };
|
||||
|
||||
// ...
|
||||
|
||||
// Add this code for firstLayer
|
||||
firstLayer.on('dragstart', (pointer) => {
|
||||
firstDragStartPoint.x = pointer.x;
|
||||
firstDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
firstLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(firstDragStartPoint.x, firstDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
|
||||
firstTextLayer.setVisible(false);
|
||||
secondTextLayer.setVisible(true);
|
||||
audioTwoAudio.play();
|
||||
secondLayer.setVisible(true);
|
||||
firstLayer.setAlpha(1);
|
||||
secondLayer.setAlpha(0.5);
|
||||
thirdLayer.setAlpha(0.5);
|
||||
} else {
|
||||
firstLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
secondLayer.on('dragstart', (pointer) => {
|
||||
secondDragStartPoint.x = pointer.x;
|
||||
secondDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
secondLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(secondDragStartPoint.x, secondDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
secondTextLayer.setVisible(false);
|
||||
thirdTextLayer.setVisible(true);
|
||||
audioThreeAudio.play();
|
||||
thirdLayer.setVisible(true);
|
||||
secondLayer.setAlpha(1);
|
||||
thirdLayer.setAlpha(0.5);
|
||||
} else {
|
||||
secondLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
// Add this code for thirdLayer
|
||||
thirdLayer.on('dragstart', (pointer) => {
|
||||
thirdDragStartPoint.x = pointer.x;
|
||||
thirdDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
thirdLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(thirdDragStartPoint.x, thirdDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
thirdLayer.setAlpha(1);
|
||||
thirdTextLayer.setVisible(false);
|
||||
} else {
|
||||
thirdLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
graphics.moveTo(pointer.x, pointer.y);
|
||||
// console.log("Start Position", pointer.x, pointer.y)
|
||||
});
|
||||
|
||||
this.input.on('pointerup', function () {
|
||||
isDrawing = false;
|
||||
});
|
||||
|
||||
this.input.on('pointermove', function (pointer) {
|
||||
if (!isDrawing) return;
|
||||
|
||||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
}
|
||||
|
||||
function update() {
|
||||
}
|
||||
|
||||
</script>
|
||||
357
src/pages/capital-letter/B.astro
Normal file
357
src/pages/capital-letter/B.astro
Normal file
@@ -0,0 +1,357 @@
|
||||
---
|
||||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script is:inline>
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
width: isMobile ? window.innerWidth : window.innerWidth / 2,
|
||||
height: window.innerHeight / 2,
|
||||
};
|
||||
|
||||
const config = {
|
||||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
},
|
||||
scene: {
|
||||
preload: preload,
|
||||
create: create,
|
||||
update: update
|
||||
}
|
||||
};
|
||||
// backgroundImage.png
|
||||
const game = new Phaser.Game(config);
|
||||
const customWidth = window.innerWidth;
|
||||
const customHeight = window.innerHeight;
|
||||
let firstLayer, secondLayer, thirdLayer;
|
||||
let graphics;
|
||||
let isDrawing = false;
|
||||
|
||||
if(isMobile){
|
||||
cloudeSize = 200;
|
||||
cloudHeight = 340;
|
||||
canvasScale = 0.14
|
||||
canvasHeight = 35;
|
||||
letterHeight = 58;
|
||||
letterScale = 0.85;
|
||||
backgroundScale = 0.8;
|
||||
sunScale = 0.1;
|
||||
sunScalePlus = 0.15;
|
||||
sunWidth = 70;
|
||||
sunHeight = 70;
|
||||
beanieScale = 0.35;
|
||||
beanieScalePlus = 0.38;
|
||||
beanieWidth = 135;
|
||||
beanieHeight = 170;
|
||||
animatedBHeight = 32;
|
||||
} else{
|
||||
cloudeSize = 500;
|
||||
cloudHeight = 250;
|
||||
canvasScale = 0.195;
|
||||
canvasHeight = 20;
|
||||
letterHeight = 50;
|
||||
letterScale = 1;
|
||||
backgroundScale = 1;
|
||||
sunScale = 0.2;
|
||||
sunScalePlus = 0.25;
|
||||
sunWidth = 200;
|
||||
sunHeight = 100;
|
||||
beanieScale = 0.4;
|
||||
beanieScalePlus = 0.44;
|
||||
beanieWidth = 200;
|
||||
beanieHeight = 245;
|
||||
animatedBHeight = 20;
|
||||
}
|
||||
// let hideButton;
|
||||
|
||||
function preload() {
|
||||
this.load.video('animatedB', '/assets/animated-letter/capital_b.mp4');
|
||||
this.load.svg('letterB', '/assets/capital-letter/b.svg');
|
||||
this.load.svg('layer1', '/assets/capital-letter/b_l1.svg');
|
||||
this.load.svg('layer2', '/assets/capital-letter/b_l2.svg');
|
||||
this.load.svg('layer3', '/assets/capital-letter/b_l3.svg');
|
||||
this.load.audio('audioOne', '/assets/audio/tall-down.mp3');
|
||||
this.load.audio('audioTwo', '/assets/audio/slide-around.mp3');
|
||||
this.load.image('topLogo', '/assets/top_logo.png');
|
||||
this.load.svg('succesImage', '/assets/svg/tick.svg');
|
||||
this.load.svg('hintImage', '/assets/svg/hint.svg');
|
||||
this.load.svg('handPointer', '/assets/svg/hand.svg');
|
||||
this.load.image('backgroundImage', '/assets/bg6.png');
|
||||
this.load.image('cloud', '/assets/cloud.png');
|
||||
this.load.image('canvas', '/assets/canvas4.png');
|
||||
// this.load.image('beanie', '/assets/beanie.png');
|
||||
this.load.image('beanie', '/assets/beanieImage.png');
|
||||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
}
|
||||
|
||||
function create() {
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : B", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
// this.add.image(customWidth / 2, 50, 'cloud').setDepth(1.9);
|
||||
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
const sun = this.add.sprite(customWidth - sunWidth, sunHeight, 'sun').setScale(sunScale).setDepth(-1.9);
|
||||
const beanie = this.add.sprite(customWidth / 2 - beanieWidth, customHeight / 2 - beanieHeight, 'beanie').setScale(beanieScale).setDepth(1.9);
|
||||
|
||||
|
||||
const scaleFactor = sunScalePlus; // Scale factor (2 means double the size)
|
||||
const duration = 3000; // Duration of the animation in milliseconds
|
||||
|
||||
// Create a scaling tween
|
||||
this.tweens.add({
|
||||
targets: sun,
|
||||
scaleX: scaleFactor,
|
||||
scaleY: scaleFactor,
|
||||
duration: duration,
|
||||
ease: 'Linear',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const beaniescaleFactor = beanieScalePlus; // Scale factor (2 means double the size)
|
||||
const beanieduration = 2500;
|
||||
this.tweens.add({
|
||||
targets: beanie,
|
||||
scaleX: beaniescaleFactor + 0.004,
|
||||
scaleY: beaniescaleFactor,
|
||||
duration: beanieduration,
|
||||
ease: 'Redial',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const backgroundImages = this.add.image(customWidth / 2, customHeight /2, 'backgroundImage').setDepth(-2).setScale(backgroundScale);
|
||||
this.add.image(customWidth / 2 - 30, customHeight / 2 + letterHeight, 'letterB').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2 - 30, customHeight / 2 + letterHeight, 'letterB').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'animatedB').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
maskGraphics.fillRect(customWidth / 2 - (canvas.width * canvasScale) / 2, customHeight / 2 + canvasHeight - (canvas.height * canvasScale) / 2, canvas.width * canvasScale, canvas.height * canvasScale);
|
||||
const mask = maskGraphics.createGeometryMask();
|
||||
|
||||
|
||||
|
||||
let hideButton = this.add.text(customWidth / 2 - 65, customHeight / 1.1, "Let`s Do", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(customWidth / 2 - 50, customHeight / 1.1, "Help!", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 20;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : B', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
const animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedBHeight, 'animatedB').setDepth(2).setScale(0.73);
|
||||
|
||||
// Play the video
|
||||
animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
||||
// You can set additional properties for the video, such as loop and mute:
|
||||
animatedLetter.setLoop(true); // Loop the video
|
||||
animatedLetter.setMute(false); // Unmute the video
|
||||
animatedLetter.on('complete', function () {
|
||||
// Video playback is complete
|
||||
// You can add your code here for what to do when the video finishes.
|
||||
});
|
||||
|
||||
let textX, textY;
|
||||
|
||||
firstLayer = this.add.image(customWidth / 2 - 30, customHeight / 2 + letterHeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Tall Down',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
firstLayer.setAlpha(0.5);
|
||||
firstLayer.setInteractive({ draggable: true });
|
||||
|
||||
secondLayer = this.add.image(customWidth / 2 - 30, customHeight / 2 + letterHeight, 'layer2').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
const secondTextLayer = this.add.text(textX, textY, '2. Slide Around',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioTwoAudio = this.sound.add('audioTwo');
|
||||
secondTextLayer.setVisible(false);
|
||||
secondLayer.setDepth(1);
|
||||
secondLayer.setAlpha(0.5);
|
||||
secondLayer.setInteractive({ draggable: true });
|
||||
secondLayer.setVisible(false);
|
||||
|
||||
thirdLayer = this.add.image(customWidth / 2 - 30, customHeight / 2 + letterHeight, 'layer3').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 3 : customWidth * 0.75;
|
||||
const thirdTextLayer = this.add.text(textX, textY, '3. Slide Around', { font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioTHreeAudio = this.sound.add('audioTwo');
|
||||
thirdTextLayer.setVisible(false);
|
||||
thirdLayer.setDepth(1.1);
|
||||
// thirdLayer.setScale(1.15);
|
||||
thirdLayer.setAlpha(0.5);
|
||||
thirdLayer.setInteractive({ draggable: true });
|
||||
thirdLayer.setVisible(false);
|
||||
|
||||
// Add these variables to keep track of start points
|
||||
let firstDragStartPoint = { x: 0, y: 0 };
|
||||
let secondDragStartPoint = { x: 0, y: 0 };
|
||||
let thirdDragStartPoint = { x: 0, y: 0 };
|
||||
|
||||
// ...
|
||||
|
||||
// Add this code for firstLayer
|
||||
firstLayer.on('dragstart', (pointer) => {
|
||||
firstDragStartPoint.x = pointer.x;
|
||||
firstDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
firstLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(firstDragStartPoint.x, firstDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
|
||||
firstTextLayer.setVisible(false);
|
||||
secondTextLayer.setVisible(true);
|
||||
audioTwoAudio.play();
|
||||
secondLayer.setVisible(true);
|
||||
firstLayer.setAlpha(1);
|
||||
secondLayer.setAlpha(0.5);
|
||||
thirdLayer.setAlpha(0.5);
|
||||
} else {
|
||||
firstLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
// Repeat the above code for secondLayer and thirdLayer
|
||||
|
||||
// Add this code for secondLayer
|
||||
secondLayer.on('dragstart', (pointer) => {
|
||||
secondDragStartPoint.x = pointer.x;
|
||||
secondDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
secondLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(secondDragStartPoint.x, secondDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
secondTextLayer.setVisible(false);
|
||||
thirdTextLayer.setVisible(true);
|
||||
audioTHreeAudio.play();
|
||||
thirdLayer.setVisible(true);
|
||||
secondLayer.setAlpha(1);
|
||||
thirdLayer.setAlpha(0.5);
|
||||
} else {
|
||||
secondLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
// Add this code for thirdLayer
|
||||
thirdLayer.on('dragstart', (pointer) => {
|
||||
thirdDragStartPoint.x = pointer.x;
|
||||
thirdDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
thirdLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(thirdDragStartPoint.x, thirdDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
thirdLayer.setAlpha(1);
|
||||
thirdTextLayer.setVisible(false);
|
||||
} else {
|
||||
thirdLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
graphics.moveTo(pointer.x, pointer.y);
|
||||
console.log("Start Position", pointer.x, pointer.y)
|
||||
});
|
||||
|
||||
this.input.on('pointerup', function () {
|
||||
isDrawing = false;
|
||||
});
|
||||
|
||||
this.input.on('pointermove', function (pointer) {
|
||||
if (!isDrawing) return;
|
||||
|
||||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
|
||||
// Start Position 626 317
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
286
src/pages/capital-letter/C.astro
Normal file
286
src/pages/capital-letter/C.astro
Normal file
@@ -0,0 +1,286 @@
|
||||
---
|
||||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script is:inline>
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
width: isMobile ? window.innerWidth : window.innerWidth / 2,
|
||||
height: window.innerHeight / 2,
|
||||
};
|
||||
|
||||
const config = {
|
||||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
},
|
||||
scene: {
|
||||
preload: preload,
|
||||
create: create,
|
||||
update: update
|
||||
}
|
||||
};
|
||||
// backgroundImage.png
|
||||
const game = new Phaser.Game(config);
|
||||
const customWidth = window.innerWidth;
|
||||
const customHeight = window.innerHeight;
|
||||
let firstLayer, secondLayer, thirdLayer;
|
||||
let graphics;
|
||||
let isDrawing = false;
|
||||
|
||||
if(isMobile){
|
||||
cloudeSize = 200;
|
||||
cloudHeight = 340;
|
||||
canvasScale = 0.14
|
||||
canvasHeight = 35;
|
||||
letterHeight = 90;
|
||||
letterScale = 1;
|
||||
backgroundScale = 0.8;
|
||||
sunScale = 0.1;
|
||||
sunScalePlus = 0.15;
|
||||
sunWidth = 70;
|
||||
sunHeight = 70;
|
||||
beanieScale = 0.35;
|
||||
beanieScalePlus = 0.38;
|
||||
beanieWidth = 135;
|
||||
beanieHeight = 170;
|
||||
animatedAHeight = 32;
|
||||
} else{
|
||||
cloudeSize = 500;
|
||||
cloudHeight = 250;
|
||||
canvasScale = 0.195;
|
||||
canvasHeight = 20;
|
||||
letterHeight = 50;
|
||||
letterScale = 1;
|
||||
backgroundScale = 1;
|
||||
sunScale = 0.2;
|
||||
sunScalePlus = 0.25;
|
||||
sunWidth = 200;
|
||||
sunHeight = 100;
|
||||
beanieScale = 0.4;
|
||||
beanieScalePlus = 0.44;
|
||||
beanieWidth = 200;
|
||||
beanieHeight = 245;
|
||||
animatedAHeight = 20;
|
||||
}
|
||||
// let hideButton;
|
||||
|
||||
function preload() {
|
||||
this.load.video('animatedA', '/assets/animated-letter/capital_c.mp4');
|
||||
this.load.svg('letterC', '/assets/capital-letter/c.svg');
|
||||
this.load.svg('layer1', '/assets/capital-letter/c.svg');
|
||||
this.load.audio('audioOne', '/assets/audio/hook-around.mp3');
|
||||
this.load.image('topLogo', '/assets/top_logo.png');
|
||||
this.load.svg('succesImage', '/assets/svg/tick.svg');
|
||||
this.load.svg('hintImage', '/assets/svg/hint.svg');
|
||||
this.load.svg('handPointer', '/assets/svg/hand.svg');
|
||||
this.load.image('backgroundImage', '/assets/bg6.png');
|
||||
this.load.image('cloud', '/assets/cloud.png');
|
||||
this.load.image('canvas', '/assets/canvas4.png');
|
||||
this.load.image('beanie', '/assets/beanieImage.png');
|
||||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
}
|
||||
|
||||
function create() {
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : C", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
// this.add.image(customWidth / 2, 50, 'cloud').setDepth(1.9);
|
||||
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
const sun = this.add.sprite(customWidth - sunWidth, sunHeight, 'sun').setScale(sunScale).setDepth(-1.9);
|
||||
const beanie = this.add.sprite(customWidth / 2 - beanieWidth, customHeight / 2 - beanieHeight, 'beanie').setScale(beanieScale).setDepth(1.9);
|
||||
|
||||
|
||||
const scaleFactor = sunScalePlus; // Scale factor (2 means double the size)
|
||||
const duration = 3000; // Duration of the animation in milliseconds
|
||||
|
||||
// Create a scaling tween
|
||||
this.tweens.add({
|
||||
targets: sun,
|
||||
scaleX: scaleFactor,
|
||||
scaleY: scaleFactor,
|
||||
duration: duration,
|
||||
ease: 'Linear',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const beaniescaleFactor = beanieScalePlus; // Scale factor (2 means double the size)
|
||||
const beanieduration = 2500;
|
||||
this.tweens.add({
|
||||
targets: beanie,
|
||||
scaleX: beaniescaleFactor + 0.004,
|
||||
scaleY: beaniescaleFactor,
|
||||
duration: beanieduration,
|
||||
ease: 'Redial',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const backgroundImages = this.add.image(customWidth / 2, customHeight /2, 'backgroundImage').setDepth(-2).setScale(backgroundScale);
|
||||
this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'letterC').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2 + 90, customHeight / 2 + letterHeight, 'letterC').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'animatedA').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
maskGraphics.fillRect(customWidth / 2 - (canvas.width * canvasScale) / 2, customHeight / 2 + canvasHeight - (canvas.height * canvasScale) / 2, canvas.width * canvasScale, canvas.height * canvasScale);
|
||||
const mask = maskGraphics.createGeometryMask();
|
||||
|
||||
|
||||
|
||||
let hideButton = this.add.text(customWidth / 2 - 65, customHeight / 1.1, "Let`s Do", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(customWidth / 2 - 50, customHeight / 1.1, "Help!", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 20;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : C', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
const animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedAHeight, 'animatedA').setDepth(2).setScale(0.73);
|
||||
|
||||
// Play the video
|
||||
animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
||||
// You can set additional properties for the video, such as loop and mute:
|
||||
animatedLetter.setLoop(true); // Loop the video
|
||||
animatedLetter.setMute(false); // Unmute the video
|
||||
animatedLetter.on('complete', function () {
|
||||
// Video playback is complete
|
||||
// You can add your code here for what to do when the video finishes.
|
||||
});
|
||||
|
||||
let textX, textY;
|
||||
|
||||
firstLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Hook Around',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
firstLayer.setAlpha(0.5);
|
||||
firstLayer.setInteractive({ draggable: true });
|
||||
|
||||
|
||||
|
||||
// Add these variables to keep track of start points
|
||||
let firstDragStartPoint = { x: 0, y: 0 };
|
||||
|
||||
// ...
|
||||
|
||||
// Add this code for firstLayer
|
||||
firstLayer.on('dragstart', (pointer) => {
|
||||
firstDragStartPoint.x = pointer.x;
|
||||
firstDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
firstLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(firstDragStartPoint.x, firstDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 50) {
|
||||
|
||||
firstTextLayer.setVisible(false);
|
||||
firstLayer.setAlpha(1);
|
||||
} else {
|
||||
firstLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
graphics.moveTo(pointer.x, pointer.y);
|
||||
});
|
||||
|
||||
this.input.on('pointerup', function () {
|
||||
isDrawing = false;
|
||||
});
|
||||
|
||||
this.input.on('pointermove', function (pointer) {
|
||||
if (!isDrawing) return;
|
||||
|
||||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
319
src/pages/capital-letter/D.astro
Normal file
319
src/pages/capital-letter/D.astro
Normal file
@@ -0,0 +1,319 @@
|
||||
---
|
||||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script is:inline>
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
width: isMobile ? window.innerWidth : window.innerWidth / 2,
|
||||
height: window.innerHeight / 2,
|
||||
};
|
||||
|
||||
const config = {
|
||||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
},
|
||||
scene: {
|
||||
preload: preload,
|
||||
create: create,
|
||||
update: update
|
||||
}
|
||||
};
|
||||
// backgroundImage.png
|
||||
const game = new Phaser.Game(config);
|
||||
const customWidth = window.innerWidth;
|
||||
const customHeight = window.innerHeight;
|
||||
let firstLayer, secondLayer;
|
||||
let graphics;
|
||||
let isDrawing = false;
|
||||
|
||||
if(isMobile){
|
||||
cloudeSize = 200;
|
||||
cloudHeight = 340;
|
||||
canvasScale = 0.14
|
||||
canvasHeight = 35;
|
||||
letterHeight = 58;
|
||||
letterScale = 0.85;
|
||||
backgroundScale = 0.8;
|
||||
sunScale = 0.1;
|
||||
sunScalePlus = 0.15;
|
||||
sunWidth = 70;
|
||||
sunHeight = 70;
|
||||
beanieScale = 0.35;
|
||||
beanieScalePlus = 0.38;
|
||||
beanieWidth = 135;
|
||||
beanieHeight = 170;
|
||||
animatedDHeight = 32;
|
||||
} else{
|
||||
cloudeSize = 500;
|
||||
cloudHeight = 250;
|
||||
canvasScale = 0.195;
|
||||
canvasHeight = 20;
|
||||
letterHeight = 50;
|
||||
letterScale = 1;
|
||||
backgroundScale = 1;
|
||||
sunScale = 0.2;
|
||||
sunScalePlus = 0.25;
|
||||
sunWidth = 200;
|
||||
sunHeight = 100;
|
||||
beanieScale = 0.4;
|
||||
beanieScalePlus = 0.44;
|
||||
beanieWidth = 200;
|
||||
beanieHeight = 245;
|
||||
animatedDHeight = 20;
|
||||
}
|
||||
// let hideButton;
|
||||
|
||||
function preload() {
|
||||
this.load.video('animatedD', '/assets/animated-letter/capital_d.mp4');
|
||||
this.load.svg('letterD', '/assets/capital-letter/d.svg');
|
||||
this.load.svg('layer1', '/assets/capital-letter/d_l1.svg');
|
||||
this.load.svg('layer2', '/assets/capital-letter/d_l2.svg');
|
||||
this.load.audio('audioOne', '/assets/audio/tall-down.mp3');
|
||||
this.load.audio('audioTwo', '/assets/audio/slide-around.mp3');
|
||||
this.load.image('topLogo', '/assets/top_logo.png');
|
||||
this.load.svg('succesImage', '/assets/svg/tick.svg');
|
||||
this.load.svg('hintImage', '/assets/svg/hint.svg');
|
||||
this.load.svg('handPointer', '/assets/svg/hand.svg');
|
||||
this.load.image('backgroundImage', '/assets/bg6.png');
|
||||
this.load.image('cloud', '/assets/cloud.png');
|
||||
this.load.image('canvas', '/assets/canvas4.png');
|
||||
this.load.image('beanie', '/assets/beanieImage.png');
|
||||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
}
|
||||
|
||||
function create() {
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : D", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
// this.add.image(customWidth / 2, 50, 'cloud').setDepth(1.9);
|
||||
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
const sun = this.add.sprite(customWidth - sunWidth, sunHeight, 'sun').setScale(sunScale).setDepth(-1.9);
|
||||
const beanie = this.add.sprite(customWidth / 2 - beanieWidth, customHeight / 2 - beanieHeight, 'beanie').setScale(beanieScale).setDepth(1.9);
|
||||
|
||||
|
||||
const scaleFactor = sunScalePlus; // Scale factor (2 means double the size)
|
||||
const duration = 3000; // Duration of the animation in milliseconds
|
||||
|
||||
// Create a scaling tween
|
||||
this.tweens.add({
|
||||
targets: sun,
|
||||
scaleX: scaleFactor,
|
||||
scaleY: scaleFactor,
|
||||
duration: duration,
|
||||
ease: 'Linear',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const beaniescaleFactor = beanieScalePlus; // Scale factor (2 means double the size)
|
||||
const beanieduration = 2500;
|
||||
this.tweens.add({
|
||||
targets: beanie,
|
||||
scaleX: beaniescaleFactor + 0.004,
|
||||
scaleY: beaniescaleFactor,
|
||||
duration: beanieduration,
|
||||
ease: 'Redial',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const backgroundImages = this.add.image(customWidth / 2, customHeight /2, 'backgroundImage').setDepth(-2).setScale(backgroundScale);
|
||||
this.add.image(customWidth / 2 - 30, customHeight / 2 + letterHeight, 'letterD').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2 - 30, customHeight / 2 + letterHeight, 'letterD').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'animatedD').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
maskGraphics.fillRect(customWidth / 2 - (canvas.width * canvasScale) / 2, customHeight / 2 + canvasHeight - (canvas.height * canvasScale) / 2, canvas.width * canvasScale, canvas.height * canvasScale);
|
||||
const mask = maskGraphics.createGeometryMask();
|
||||
|
||||
|
||||
|
||||
let hideButton = this.add.text(customWidth / 2 - 65, customHeight / 1.1, "Let`s Do", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(customWidth / 2 - 50, customHeight / 1.1, "Help!", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 20;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : D', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
const animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedDHeight, 'animatedD').setDepth(2).setScale(0.73);
|
||||
|
||||
// Play the video
|
||||
animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
||||
// You can set additional properties for the video, such as loop and mute:
|
||||
animatedLetter.setLoop(true); // Loop the video
|
||||
animatedLetter.setMute(false); // Unmute the video
|
||||
animatedLetter.on('complete', function () {
|
||||
// Video playback is complete
|
||||
// You can add your code here for what to do when the video finishes.
|
||||
});
|
||||
|
||||
let textX, textY;
|
||||
|
||||
firstLayer = this.add.image(customWidth / 2 - 30, customHeight / 2 + letterHeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Tall Down',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
firstLayer.setAlpha(0.5);
|
||||
firstLayer.setInteractive({ draggable: true });
|
||||
|
||||
secondLayer = this.add.image(customWidth / 2 - 30, customHeight / 2 + letterHeight, 'layer2').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
const secondTextLayer = this.add.text(textX, textY, '2. Slide Around',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioTwoAudio = this.sound.add('audioTwo');
|
||||
secondTextLayer.setVisible(false);
|
||||
secondLayer.setDepth(1);
|
||||
secondLayer.setAlpha(0.5);
|
||||
secondLayer.setInteractive({ draggable: true });
|
||||
secondLayer.setVisible(false);
|
||||
|
||||
|
||||
// Add these variables to keep track of start points
|
||||
let firstDragStartPoint = { x: 0, y: 0 };
|
||||
let secondDragStartPoint = { x: 0, y: 0 };
|
||||
|
||||
// ...
|
||||
|
||||
// Add this code for firstLayer
|
||||
firstLayer.on('dragstart', (pointer) => {
|
||||
firstDragStartPoint.x = pointer.x;
|
||||
firstDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
firstLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(firstDragStartPoint.x, firstDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
|
||||
firstTextLayer.setVisible(false);
|
||||
secondTextLayer.setVisible(true);
|
||||
audioTwoAudio.play();
|
||||
secondLayer.setVisible(true);
|
||||
firstLayer.setAlpha(1);
|
||||
secondLayer.setAlpha(0.5);
|
||||
} else {
|
||||
firstLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
``
|
||||
// Repeat the above code for secondLayer and thirdLayer
|
||||
|
||||
// Add this code for secondLayer
|
||||
secondLayer.on('dragstart', (pointer) => {
|
||||
secondDragStartPoint.x = pointer.x;
|
||||
secondDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
secondLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(secondDragStartPoint.x, secondDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >=100) {
|
||||
secondTextLayer.setVisible(false);
|
||||
secondLayer.setAlpha(1);
|
||||
} else {
|
||||
secondLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
graphics.moveTo(pointer.x, pointer.y);
|
||||
console.log("Start Position", pointer.x, pointer.y)
|
||||
});
|
||||
|
||||
this.input.on('pointerup', function () {
|
||||
isDrawing = false;
|
||||
});
|
||||
|
||||
this.input.on('pointermove', function (pointer) {
|
||||
if (!isDrawing) return;
|
||||
|
||||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
387
src/pages/capital-letter/E.astro
Normal file
387
src/pages/capital-letter/E.astro
Normal file
@@ -0,0 +1,387 @@
|
||||
---
|
||||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script is:inline>
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
width: isMobile ? window.innerWidth : window.innerWidth / 2,
|
||||
height: window.innerHeight / 2,
|
||||
};
|
||||
|
||||
const config = {
|
||||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
},
|
||||
scene: {
|
||||
preload: preload,
|
||||
create: create,
|
||||
update: update
|
||||
}
|
||||
};
|
||||
// backgroundImage.png
|
||||
const game = new Phaser.Game(config);
|
||||
const customWidth = window.innerWidth;
|
||||
const customHeight = window.innerHeight;
|
||||
let firstLayer, secondLayer, thirdLayer, fourthLayer;
|
||||
let graphics;
|
||||
let isDrawing = false;
|
||||
|
||||
if(isMobile){
|
||||
cloudeSize = 200;
|
||||
cloudHeight = 340;
|
||||
canvasScale = 0.14
|
||||
canvasHeight = 35;
|
||||
letterHeight = 60;
|
||||
letterScale = 0.85;
|
||||
backgroundScale = 0.8;
|
||||
sunScale = 0.1;
|
||||
sunScalePlus = 0.15;
|
||||
sunWidth = 70;
|
||||
sunHeight = 70;
|
||||
beanieScale = 0.35;
|
||||
beanieScalePlus = 0.38;
|
||||
beanieWidth = 135;
|
||||
beanieHeight = 170;
|
||||
animatedAHeight = 32;
|
||||
} else{
|
||||
cloudeSize = 500;
|
||||
cloudHeight = 250;
|
||||
canvasScale = 0.195;
|
||||
canvasHeight = 20;
|
||||
letterHeight = 50;
|
||||
letterScale = 1;
|
||||
backgroundScale = 1;
|
||||
sunScale = 0.2;
|
||||
sunScalePlus = 0.25;
|
||||
sunWidth = 200;
|
||||
sunHeight = 100;
|
||||
beanieScale = 0.4;
|
||||
beanieScalePlus = 0.44;
|
||||
beanieWidth = 200;
|
||||
beanieHeight = 245;
|
||||
animatedAHeight = 20;
|
||||
}
|
||||
function preload() {
|
||||
this.load.video('animatedA', '/assets/animated-letter/a.mp4');
|
||||
this.load.svg('letterE', '/assets/capital-letter/e.svg');
|
||||
this.load.svg('layer1', '/assets/capital-letter/e_l1.svg');
|
||||
this.load.svg('layer2', '/assets/capital-letter/e_l2.svg');
|
||||
this.load.svg('layer3', '/assets/capital-letter/e_l3.svg');
|
||||
this.load.svg('layer4', '/assets/capital-letter/e_l4.svg');
|
||||
this.load.audio('audioOne', '/assets/audio/tall-down.mp3');
|
||||
this.load.audio('audioTwo', '/assets/audio/slide.mp3');
|
||||
this.load.audio('audioThree', '/assets/audio/slide.mp3');
|
||||
this.load.image('topLogo', '/assets/top_logo.png');
|
||||
this.load.svg('succesImage', '/assets/svg/tick.svg');
|
||||
this.load.svg('hintImage', '/assets/svg/hint.svg');
|
||||
this.load.svg('handPointer', '/assets/svg/hand.svg');
|
||||
this.load.image('backgroundImage', '/assets/bg6.png');
|
||||
this.load.image('cloud', '/assets/cloud.png');
|
||||
this.load.image('canvas', '/assets/canvas4.png');
|
||||
this.load.image('beanie', '/assets/beanieImage.png');
|
||||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
}
|
||||
|
||||
function create() {
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : E", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
// this.add.image(customWidth / 2, 50, 'cloud').setDepth(1.9);
|
||||
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
const sun = this.add.sprite(customWidth - sunWidth, sunHeight, 'sun').setScale(sunScale).setDepth(-1.9);
|
||||
const beanie = this.add.sprite(customWidth / 2 - beanieWidth, customHeight / 2 - beanieHeight, 'beanie').setScale(beanieScale).setDepth(1.9);
|
||||
|
||||
|
||||
const scaleFactor = sunScalePlus; // Scale factor (2 means double the size)
|
||||
const duration = 3000; // Duration of the animation in milliseconds
|
||||
|
||||
// Create a scaling tween
|
||||
this.tweens.add({
|
||||
targets: sun,
|
||||
scaleX: scaleFactor,
|
||||
scaleY: scaleFactor,
|
||||
duration: duration,
|
||||
ease: 'Linear',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const beaniescaleFactor = beanieScalePlus; // Scale factor (2 means double the size)
|
||||
const beanieduration = 2500;
|
||||
this.tweens.add({
|
||||
targets: beanie,
|
||||
scaleX: beaniescaleFactor + 0.004,
|
||||
scaleY: beaniescaleFactor,
|
||||
duration: beanieduration,
|
||||
ease: 'Redial',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const backgroundImages = this.add.image(customWidth / 2, customHeight /2, 'backgroundImage').setDepth(-2).setScale(backgroundScale);
|
||||
this.add.image(customWidth / 2 - 20, customHeight / 2 + letterHeight, 'letterE').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2 - 20, customHeight / 2 + letterHeight, 'letterE').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'animatedA').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
maskGraphics.fillRect(customWidth / 2 - (canvas.width * canvasScale) / 2, customHeight / 2 + canvasHeight - (canvas.height * canvasScale) / 2, canvas.width * canvasScale, canvas.height * canvasScale);
|
||||
const mask = maskGraphics.createGeometryMask();
|
||||
|
||||
|
||||
|
||||
let hideButton = this.add.text(customWidth / 2 - 65, customHeight / 1.1, "Let`s Do", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(customWidth / 2 - 50, customHeight / 1.1, "Help!", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 20;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : E', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
const animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedAHeight, 'animatedA').setDepth(2).setScale(0.73);
|
||||
|
||||
// Play the video
|
||||
animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
||||
// You can set additional properties for the video, such as loop and mute:
|
||||
animatedLetter.setLoop(true); // Loop the video
|
||||
animatedLetter.setMute(false); // Unmute the video
|
||||
animatedLetter.on('complete', function () {
|
||||
// Video playback is complete
|
||||
// You can add your code here for what to do when the video finishes.
|
||||
});
|
||||
|
||||
let textX, textY;
|
||||
|
||||
firstLayer = this.add.image(customWidth / 2 - 20, customHeight / 2 + letterHeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Tall Down',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
firstLayer.setAlpha(0.5);
|
||||
firstLayer.setInteractive({ draggable: true });
|
||||
|
||||
secondLayer = this.add.image(customWidth / 2 - 20, customHeight / 2 + letterHeight, 'layer2').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
const secondTextLayer = this.add.text(textX, textY, '2. Slide',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioTwoAudio = this.sound.add('audioTwo');
|
||||
secondTextLayer.setVisible(false);
|
||||
secondLayer.setDepth(1);
|
||||
secondLayer.setAlpha(0.5);
|
||||
secondLayer.setInteractive({ draggable: true });
|
||||
secondLayer.setVisible(false);
|
||||
|
||||
thirdLayer = this.add.image(customWidth / 2 - 20, customHeight / 2 + letterHeight, 'layer3').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 3 : customWidth * 0.75;
|
||||
const thirdTextLayer = this.add.text(textX, textY, '3. Slide', { font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioThreeAudio = this.sound.add('audioTwo');
|
||||
thirdTextLayer.setVisible(false);
|
||||
thirdLayer.setDepth(1.1);
|
||||
// thirdLayer.setScale(1.15);
|
||||
thirdLayer.setAlpha(0.5);
|
||||
thirdLayer.setInteractive({ draggable: true });
|
||||
thirdLayer.setVisible(false);
|
||||
|
||||
fourthLayer = this.add.image(customWidth / 2 - 20, customHeight / 2 + letterHeight, 'layer4').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 3 : customWidth * 0.75;
|
||||
const fourthTextLayer = this.add.text(textX, textY, '4. Slide', { font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioFourthAudio = this.sound.add('audioTwo');
|
||||
fourthTextLayer.setVisible(false);
|
||||
fourthLayer.setDepth(1.1);
|
||||
// fourthLayer.setScale(1.15);
|
||||
fourthLayer.setAlpha(0.5);
|
||||
fourthLayer.setInteractive({ draggable: true });
|
||||
fourthLayer.setVisible(false);
|
||||
|
||||
// Add these variables to keep track of start points
|
||||
let firstDragStartPoint = { x: 0, y: 0 };
|
||||
let secondDragStartPoint = { x: 0, y: 0 };
|
||||
let thirdDragStartPoint = { x: 0, y: 0 };
|
||||
let fourthDragStartPoint = { x: 0, y: 0 };
|
||||
|
||||
// Add this code for firstLayer
|
||||
firstLayer.on('dragstart', (pointer) => {
|
||||
firstDragStartPoint.x = pointer.x;
|
||||
firstDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
firstLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(firstDragStartPoint.x, firstDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
firstTextLayer.setVisible(false);
|
||||
secondTextLayer.setVisible(true);
|
||||
audioTwoAudio.play();
|
||||
secondLayer.setVisible(true);
|
||||
firstLayer.setAlpha(1);
|
||||
secondLayer.setAlpha(0.5);
|
||||
thirdLayer.setAlpha(0.5);
|
||||
fourthLayer.setAlpha(0.5);
|
||||
} else {
|
||||
firstLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
// Repeat the above code for secondLayer and thirdLayer
|
||||
|
||||
// Add this code for secondLayer
|
||||
secondLayer.on('dragstart', (pointer) => {
|
||||
secondDragStartPoint.x = pointer.x;
|
||||
secondDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
secondLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(secondDragStartPoint.x, secondDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
secondTextLayer.setVisible(false);
|
||||
thirdTextLayer.setVisible(true);
|
||||
audioThreeAudio.play();
|
||||
thirdLayer.setVisible(true);
|
||||
secondLayer.setAlpha(1);
|
||||
thirdLayer.setAlpha(0.5);
|
||||
fourthLayer.setAlpha(0.5);
|
||||
} else {
|
||||
secondLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
// Add this code for thirdLayer
|
||||
thirdLayer.on('dragstart', (pointer) => {
|
||||
thirdDragStartPoint.x = pointer.x;
|
||||
thirdDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
thirdLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(thirdDragStartPoint.x, thirdDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
thirdLayer.setAlpha(1);
|
||||
thirdTextLayer.setVisible(false);
|
||||
fourthTextLayer.setVisible(true);
|
||||
fourthLayer.setVisible(true);
|
||||
fourthLayer.setAlpha(0.5);
|
||||
audioFourthAudio.play();
|
||||
} else {
|
||||
thirdLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
fourthLayer.on('dragstart', (pointer) => {
|
||||
fourthDragStartPoint.x = pointer.x;
|
||||
fourthDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
fourthLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(fourthDragStartPoint.x, fourthDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
fourthLayer.setAlpha(1);
|
||||
fourthTextLayer.setVisible(false);
|
||||
} else {
|
||||
fourthLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
graphics.moveTo(pointer.x, pointer.y);
|
||||
console.log("Start Position", pointer.x, pointer.y)
|
||||
});
|
||||
|
||||
this.input.on('pointerup', function () {
|
||||
isDrawing = false;
|
||||
});
|
||||
|
||||
this.input.on('pointermove', function (pointer) {
|
||||
if (!isDrawing) return;
|
||||
|
||||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
|
||||
// Start Position 626 317
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
347
src/pages/capital-letter/F.astro
Normal file
347
src/pages/capital-letter/F.astro
Normal file
@@ -0,0 +1,347 @@
|
||||
---
|
||||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script is:inline>
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
width: isMobile ? window.innerWidth : window.innerWidth / 2,
|
||||
height: window.innerHeight / 2,
|
||||
};
|
||||
|
||||
const config = {
|
||||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
},
|
||||
scene: {
|
||||
preload: preload,
|
||||
create: create,
|
||||
update: update
|
||||
}
|
||||
};
|
||||
// backgroundImage.png
|
||||
const game = new Phaser.Game(config);
|
||||
const customWidth = window.innerWidth;
|
||||
const customHeight = window.innerHeight;
|
||||
let firstLayer, secondLayer, thirdLayer;
|
||||
let graphics;
|
||||
let isDrawing = false;
|
||||
// let x = 100;
|
||||
|
||||
// // Use x
|
||||
// console.log(x);
|
||||
|
||||
if(isMobile){
|
||||
cloudeSize = 200;
|
||||
cloudHeight = 340;
|
||||
canvasScale = 0.14
|
||||
canvasHeight = 35;
|
||||
letterHeight = 70;
|
||||
letterScale = 1;
|
||||
backgroundScale = 0.8;
|
||||
sunScale = 0.1;
|
||||
sunScalePlus = 0.15;
|
||||
sunWidth = 70;
|
||||
sunHeight = 70;
|
||||
beanieScale = 0.35;
|
||||
beanieScalePlus = 0.365;
|
||||
beanieWidth = 135;
|
||||
beanieHeight = 170;
|
||||
animatedFHeight = 35;
|
||||
animatedFScale = 0.65;
|
||||
} else{
|
||||
cloudeSize = 500;
|
||||
cloudHeight = 250;
|
||||
canvasScale = 0.195;
|
||||
canvasHeight = 20;
|
||||
letterHeight = 50;
|
||||
letterScale = 1;
|
||||
backgroundScale = 1;
|
||||
sunScale = 0.2;
|
||||
sunScalePlus = 0.25;
|
||||
sunWidth = 200;
|
||||
sunHeight = 100;
|
||||
beanieScale = 0.4;
|
||||
beanieScalePlus = 0.45;
|
||||
beanieWidth = 200;
|
||||
beanieHeight = 255;
|
||||
animatedFHeight = 20;
|
||||
animatedFScale = 0.73;
|
||||
}
|
||||
function preload() {
|
||||
this.load.video('animatedF', '/assets/animated-letter/capital_f.mp4');
|
||||
this.load.svg('letterA', '/assets/capital-letter/f.svg');
|
||||
this.load.svg('layer1', '/assets/capital-letter/f_l1.svg');
|
||||
this.load.svg('layer2', '/assets/capital-letter/f_l2.svg');
|
||||
this.load.svg('layer3', '/assets/capital-letter/f_l3.svg');
|
||||
this.load.audio('audioOne', '/assets/audio/tall-down.mp3');
|
||||
this.load.audio('audioTwo', '/assets/audio/slide.mp3');
|
||||
this.load.image('topLogo', '/assets/top_logo.png');
|
||||
this.load.svg('succesImage', '/assets/svg/tick.svg');
|
||||
this.load.svg('hintImage', '/assets/svg/hint.svg');
|
||||
this.load.svg('handPointer', '/assets/svg/hand.svg');
|
||||
this.load.image('backgroundImage', '/assets/bg6.png');
|
||||
this.load.image('cloud', '/assets/cloud.png');
|
||||
this.load.image('canvas', '/assets/canvas4.png');
|
||||
// this.load.image('beanie', '/assets/beanie.png');
|
||||
this.load.image('beanie', '/assets/beanieImage.png');
|
||||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
}
|
||||
|
||||
function create() {
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : F", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
const sun = this.add.sprite(customWidth - sunWidth, sunHeight, 'sun').setScale(sunScale).setDepth(-1.9);
|
||||
const beanie = this.add.sprite(customWidth / 2 - beanieWidth, customHeight / 2 - beanieHeight, 'beanie').setScale(beanieScale).setDepth(1.9);
|
||||
|
||||
|
||||
const scaleFactor = sunScalePlus; // Scale factor (2 means double the size)
|
||||
const duration = 3000; // Duration of the animation in milliseconds
|
||||
|
||||
// Create a scaling tween
|
||||
this.tweens.add({
|
||||
targets: sun,
|
||||
scaleX: scaleFactor,
|
||||
scaleY: scaleFactor,
|
||||
duration: duration,
|
||||
ease: 'Linear',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const beaniescaleFactor = beanieScalePlus; // Scale factor (2 means double the size)
|
||||
const beanieduration = 2500;
|
||||
this.tweens.add({
|
||||
targets: beanie,
|
||||
scaleX: beaniescaleFactor + 0.004,
|
||||
scaleY: beaniescaleFactor,
|
||||
duration: beanieduration,
|
||||
ease: 'Redial',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const backgroundImages = this.add.image(customWidth / 2, customHeight /2, 'backgroundImage').setDepth(-2).setScale(backgroundScale);
|
||||
this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'letterA').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'letterA').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'animatedF').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
maskGraphics.fillRect(customWidth / 2 - (canvas.width * canvasScale) / 2, customHeight / 2 + canvasHeight - (canvas.height * canvasScale) / 2, canvas.width * canvasScale, canvas.height * canvasScale);
|
||||
const mask = maskGraphics.createGeometryMask();
|
||||
|
||||
|
||||
|
||||
let hideButton = this.add.text(customWidth / 2 - 65, customHeight / 1.1, "Let`s Do", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(customWidth / 2 - 50, customHeight / 1.1, "Help!", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 20;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : F', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
const animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedFHeight, 'animatedF').setDepth(2).setScale(animatedFScale);
|
||||
|
||||
// Play the video
|
||||
animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
||||
// You can set additional properties for the video, such as loop and mute:
|
||||
animatedLetter.setLoop(true); // Loop the video
|
||||
animatedLetter.setMute(false); // Unmute the video
|
||||
animatedLetter.on('complete', function () {
|
||||
// add function after end video;
|
||||
});
|
||||
|
||||
let textX, textY;
|
||||
|
||||
firstLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Tall Down',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
firstLayer.setAlpha(0.5);
|
||||
firstLayer.setInteractive({ draggable: true });
|
||||
|
||||
secondLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer2').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
const secondTextLayer = this.add.text(textX, textY, '2. Slide',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioTwoAudio = this.sound.add('audioTwo');
|
||||
secondTextLayer.setVisible(false);
|
||||
secondLayer.setDepth(1);
|
||||
secondLayer.setAlpha(0.5);
|
||||
secondLayer.setInteractive({ draggable: true });
|
||||
secondLayer.setVisible(false);
|
||||
|
||||
thirdLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer3').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 3 : customWidth * 0.75;
|
||||
const thirdTextLayer = this.add.text(textX, textY, '3. Slide', { font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioThreeAudio = this.sound.add('audioTwo');
|
||||
thirdTextLayer.setVisible(false);
|
||||
thirdLayer.setDepth(1.1);
|
||||
// thirdLayer.setScale(1.15);
|
||||
thirdLayer.setAlpha(0.5);
|
||||
thirdLayer.setInteractive({ draggable: true });
|
||||
thirdLayer.setVisible(false);
|
||||
|
||||
// Add these variables to keep track of start points
|
||||
let firstDragStartPoint = { x: 0, y: 0 };
|
||||
let secondDragStartPoint = { x: 0, y: 0 };
|
||||
let thirdDragStartPoint = { x: 0, y: 0 };
|
||||
|
||||
// Add this code for firstLayer
|
||||
firstLayer.on('dragstart', (pointer) => {
|
||||
firstDragStartPoint.x = pointer.x;
|
||||
firstDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
firstLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(firstDragStartPoint.x, firstDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
|
||||
firstTextLayer.setVisible(false);
|
||||
secondTextLayer.setVisible(true);
|
||||
audioTwoAudio.play();
|
||||
secondLayer.setVisible(true);
|
||||
firstLayer.setAlpha(1);
|
||||
secondLayer.setAlpha(0.5);
|
||||
thirdLayer.setAlpha(0.5);
|
||||
} else {
|
||||
firstLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
secondLayer.on('dragstart', (pointer) => {
|
||||
secondDragStartPoint.x = pointer.x;
|
||||
secondDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
secondLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(secondDragStartPoint.x, secondDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
secondTextLayer.setVisible(false);
|
||||
thirdTextLayer.setVisible(true);
|
||||
audioThreeAudio.play();
|
||||
thirdLayer.setVisible(true);
|
||||
secondLayer.setAlpha(1);
|
||||
thirdLayer.setAlpha(0.5);
|
||||
} else {
|
||||
secondLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
// Add this code for thirdLayer
|
||||
thirdLayer.on('dragstart', (pointer) => {
|
||||
thirdDragStartPoint.x = pointer.x;
|
||||
thirdDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
thirdLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(thirdDragStartPoint.x, thirdDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
thirdLayer.setAlpha(1);
|
||||
thirdTextLayer.setVisible(false);
|
||||
} else {
|
||||
thirdLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
graphics.moveTo(pointer.x, pointer.y);
|
||||
// console.log("Start Position", pointer.x, pointer.y)
|
||||
});
|
||||
|
||||
this.input.on('pointerup', function () {
|
||||
isDrawing = false;
|
||||
});
|
||||
|
||||
this.input.on('pointermove', function (pointer) {
|
||||
if (!isDrawing) return;
|
||||
|
||||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
}
|
||||
|
||||
function update() {
|
||||
}
|
||||
|
||||
</script>
|
||||
318
src/pages/capital-letter/G.astro
Normal file
318
src/pages/capital-letter/G.astro
Normal file
@@ -0,0 +1,318 @@
|
||||
---
|
||||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script is:inline>
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
width: isMobile ? window.innerWidth : window.innerWidth / 2,
|
||||
height: window.innerHeight / 2,
|
||||
};
|
||||
|
||||
const config = {
|
||||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
},
|
||||
scene: {
|
||||
preload: preload,
|
||||
create: create,
|
||||
update: update
|
||||
}
|
||||
};
|
||||
// backgroundImage.png
|
||||
const game = new Phaser.Game(config);
|
||||
const customWidth = window.innerWidth;
|
||||
const customHeight = window.innerHeight;
|
||||
let firstLayer, secondLayer;
|
||||
let graphics;
|
||||
let isDrawing = false;
|
||||
|
||||
if(isMobile){
|
||||
cloudeSize = 200;
|
||||
cloudHeight = 340;
|
||||
canvasScale = 0.14
|
||||
canvasHeight = 35;
|
||||
letterHeight = 58;
|
||||
letterScale = 0.85;
|
||||
backgroundScale = 0.8;
|
||||
sunScale = 0.1;
|
||||
sunScalePlus = 0.15;
|
||||
sunWidth = 70;
|
||||
sunHeight = 70;
|
||||
beanieScale = 0.35;
|
||||
beanieScalePlus = 0.38;
|
||||
beanieWidth = 135;
|
||||
beanieHeight = 170;
|
||||
animatedGHeight = 32;
|
||||
} else{
|
||||
cloudeSize = 500;
|
||||
cloudHeight = 250;
|
||||
canvasScale = 0.195;
|
||||
canvasHeight = 20;
|
||||
letterHeight = 50;
|
||||
letterScale = 1;
|
||||
backgroundScale = 1;
|
||||
sunScale = 0.2;
|
||||
sunScalePlus = 0.25;
|
||||
sunWidth = 200;
|
||||
sunHeight = 100;
|
||||
beanieScale = 0.4;
|
||||
beanieScalePlus = 0.44;
|
||||
beanieWidth = 200;
|
||||
beanieHeight = 245;
|
||||
animatedGHeight = 20;
|
||||
}
|
||||
// let hideButton;
|
||||
|
||||
function preload() {
|
||||
this.load.video('animatedG', '/assets/animated-letter/capital_g.mp4');
|
||||
this.load.svg('letterG', '/assets/capital-letter/g.svg');
|
||||
this.load.svg('layer1', '/assets/capital-letter/g_l1.svg');
|
||||
this.load.svg('layer2', '/assets/capital-letter/g_l2.svg');
|
||||
this.load.audio('audioOne', '/assets/audio/hook-around.mp3');
|
||||
this.load.audio('audioTwo', '/assets/audio/slide.mp3');
|
||||
this.load.image('topLogo', '/assets/top_logo.png');
|
||||
this.load.svg('succesImage', '/assets/svg/tick.svg');
|
||||
this.load.svg('hintImage', '/assets/svg/hint.svg');
|
||||
this.load.svg('handPointer', '/assets/svg/hand.svg');
|
||||
this.load.image('backgroundImage', '/assets/bg6.png');
|
||||
this.load.image('cloud', '/assets/cloud.png');
|
||||
this.load.image('canvas', '/assets/canvas4.png');
|
||||
this.load.image('beanie', '/assets/beanieImage.png');
|
||||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
}
|
||||
|
||||
function create() {
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : D", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
// this.add.image(customWidth / 2, 50, 'cloud').setDepth(1.9);
|
||||
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
const sun = this.add.sprite(customWidth - sunWidth, sunHeight, 'sun').setScale(sunScale).setDepth(-1.9);
|
||||
const beanie = this.add.sprite(customWidth / 2 - beanieWidth, customHeight / 2 - beanieHeight, 'beanie').setScale(beanieScale).setDepth(1.9);
|
||||
|
||||
|
||||
const scaleFactor = sunScalePlus; // Scale factor (2 means double the size)
|
||||
const duration = 3000; // Duration of the animation in milliseconds
|
||||
|
||||
// Create a scaling tween
|
||||
this.tweens.add({
|
||||
targets: sun,
|
||||
scaleX: scaleFactor,
|
||||
scaleY: scaleFactor,
|
||||
duration: duration,
|
||||
ease: 'Linear',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const beaniescaleFactor = beanieScalePlus; // Scale factor (2 means double the size)
|
||||
const beanieduration = 2500;
|
||||
this.tweens.add({
|
||||
targets: beanie,
|
||||
scaleX: beaniescaleFactor + 0.004,
|
||||
scaleY: beaniescaleFactor,
|
||||
duration: beanieduration,
|
||||
ease: 'Redial',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const backgroundImages = this.add.image(customWidth / 2, customHeight /2, 'backgroundImage').setDepth(-2).setScale(backgroundScale);
|
||||
this.add.image(customWidth / 2 - 30, customHeight / 2 + letterHeight, 'letterG').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2 - 30, customHeight / 2 + letterHeight, 'letterG').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'animatedG').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
maskGraphics.fillRect(customWidth / 2 - (canvas.width * canvasScale) / 2, customHeight / 2 + canvasHeight - (canvas.height * canvasScale) / 2, canvas.width * canvasScale, canvas.height * canvasScale);
|
||||
const mask = maskGraphics.createGeometryMask();
|
||||
|
||||
|
||||
|
||||
let hideButton = this.add.text(customWidth / 2 - 65, customHeight / 1.1, "Let`s Do", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(customWidth / 2 - 50, customHeight / 1.1, "Help!", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 20;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : G', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
const animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedGHeight, 'animatedG').setDepth(2).setScale(0.73);
|
||||
|
||||
// Play the video
|
||||
animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
||||
// You can set additional properties for the video, such as loop and mute:
|
||||
animatedLetter.setLoop(true); // Loop the video
|
||||
animatedLetter.setMute(false); // Unmute the video
|
||||
animatedLetter.on('complete', function () {
|
||||
// Video playback is complete
|
||||
// You can add your code here for what to do when the video finishes.
|
||||
});
|
||||
|
||||
let textX, textY;
|
||||
|
||||
firstLayer = this.add.image(customWidth / 2 - 30, customHeight / 2 + letterHeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Hook Around',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
firstLayer.setAlpha(0.5);
|
||||
firstLayer.setInteractive({ draggable: true });
|
||||
|
||||
secondLayer = this.add.image(customWidth / 2 - 30, customHeight / 2 + letterHeight, 'layer2').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
const secondTextLayer = this.add.text(textX, textY, '2. Slide',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioTwoAudio = this.sound.add('audioTwo');
|
||||
secondTextLayer.setVisible(false);
|
||||
secondLayer.setDepth(1);
|
||||
secondLayer.setAlpha(0.5);
|
||||
secondLayer.setInteractive({ draggable: true });
|
||||
secondLayer.setVisible(false);
|
||||
|
||||
|
||||
// Add these variables to keep track of start points
|
||||
let firstDragStartPoint = { x: 0, y: 0 };
|
||||
let secondDragStartPoint = { x: 0, y: 0 };
|
||||
|
||||
// ...
|
||||
|
||||
// Add this code for firstLayer
|
||||
firstLayer.on('dragstart', (pointer) => {
|
||||
firstDragStartPoint.x = pointer.x;
|
||||
firstDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
firstLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(firstDragStartPoint.x, firstDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
|
||||
firstTextLayer.setVisible(false);
|
||||
secondTextLayer.setVisible(true);
|
||||
audioTwoAudio.play();
|
||||
secondLayer.setVisible(true);
|
||||
firstLayer.setAlpha(1);
|
||||
secondLayer.setAlpha(0.5);
|
||||
} else {
|
||||
firstLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
``
|
||||
// Repeat the above code for secondLayer and thirdLayer
|
||||
|
||||
// Add this code for secondLayer
|
||||
secondLayer.on('dragstart', (pointer) => {
|
||||
secondDragStartPoint.x = pointer.x;
|
||||
secondDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
secondLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(secondDragStartPoint.x, secondDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >=100) {
|
||||
secondTextLayer.setVisible(false);
|
||||
secondLayer.setAlpha(1);
|
||||
} else {
|
||||
secondLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
graphics.moveTo(pointer.x, pointer.y);
|
||||
console.log("Start Position", pointer.x, pointer.y)
|
||||
});
|
||||
|
||||
this.input.on('pointerup', function () {
|
||||
isDrawing = false;
|
||||
});
|
||||
|
||||
this.input.on('pointermove', function (pointer) {
|
||||
if (!isDrawing) return;
|
||||
|
||||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
350
src/pages/capital-letter/H.astro
Normal file
350
src/pages/capital-letter/H.astro
Normal file
@@ -0,0 +1,350 @@
|
||||
---
|
||||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script is:inline>
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
width: isMobile ? window.innerWidth : window.innerWidth / 2,
|
||||
height: window.innerHeight / 2,
|
||||
};
|
||||
|
||||
const config = {
|
||||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
},
|
||||
scene: {
|
||||
preload: preload,
|
||||
create: create,
|
||||
update: update
|
||||
}
|
||||
};
|
||||
// backgroundImage.png
|
||||
const game = new Phaser.Game(config);
|
||||
const customWidth = window.innerWidth;
|
||||
const customHeight = window.innerHeight;
|
||||
let firstLayer, secondLayer, thirdLayer;
|
||||
let graphics;
|
||||
let isDrawing = false;
|
||||
// let x = 100;
|
||||
|
||||
// // Use x
|
||||
// console.log(x);
|
||||
|
||||
if(isMobile){
|
||||
cloudeSize = 200;
|
||||
cloudHeight = 340;
|
||||
canvasScale = 0.14
|
||||
canvasHeight = 35;
|
||||
letterHeight = 70;
|
||||
letterScale = 1;
|
||||
backgroundScale = 0.8;
|
||||
sunScale = 0.1;
|
||||
sunScalePlus = 0.15;
|
||||
sunWidth = 70;
|
||||
sunHeight = 70;
|
||||
beanieScale = 0.35;
|
||||
beanieScalePlus = 0.365;
|
||||
beanieWidth = 135;
|
||||
beanieHeight = 170;
|
||||
animatedHHeight = 35;
|
||||
animatedHScale = 0.65;
|
||||
} else{
|
||||
cloudeSize = 500;
|
||||
cloudHeight = 250;
|
||||
canvasScale = 0.195;
|
||||
canvasHeight = 20;
|
||||
letterHeight = 50;
|
||||
letterScale = 1;
|
||||
backgroundScale = 1;
|
||||
sunScale = 0.2;
|
||||
sunScalePlus = 0.25;
|
||||
sunWidth = 200;
|
||||
sunHeight = 100;
|
||||
beanieScale = 0.4;
|
||||
beanieScalePlus = 0.45;
|
||||
beanieWidth = 200;
|
||||
beanieHeight = 255;
|
||||
animatedHHeight = 20;
|
||||
animatedHScale = 0.73;
|
||||
}
|
||||
function preload() {
|
||||
this.load.video('animatedH', '/assets/animated-letter/capital_H.mp4');
|
||||
this.load.svg('letterH', '/assets/capital-letter/h.svg');
|
||||
this.load.svg('layer1', '/assets/capital-letter/h_l1.svg');
|
||||
this.load.svg('layer2', '/assets/capital-letter/h_l2.svg');
|
||||
this.load.svg('layer3', '/assets/capital-letter/h_l3.svg');
|
||||
this.load.audio('audioOne', '/assets/audio/tall-down.mp3');
|
||||
this.load.audio('audioTwo', '/assets/audio/slide.mp3');
|
||||
this.load.image('topLogo', '/assets/top_logo.png');
|
||||
this.load.svg('succesImage', '/assets/svg/tick.svg');
|
||||
this.load.svg('hintImage', '/assets/svg/hint.svg');
|
||||
this.load.svg('handPointer', '/assets/svg/hand.svg');
|
||||
this.load.image('backgroundImage', '/assets/bg6.png');
|
||||
this.load.image('cloud', '/assets/cloud.png');
|
||||
this.load.image('canvas', '/assets/canvas4.png');
|
||||
// this.load.image('beanie', '/assets/beanie.png');
|
||||
this.load.image('beanie', '/assets/beanieImage.png');
|
||||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
}
|
||||
|
||||
function create() {
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : H", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
const sun = this.add.sprite(customWidth - sunWidth, sunHeight, 'sun').setScale(sunScale).setDepth(-1.9);
|
||||
const beanie = this.add.sprite(customWidth / 2 - beanieWidth, customHeight / 2 - beanieHeight, 'beanie').setScale(beanieScale).setDepth(1.9);
|
||||
|
||||
|
||||
const scaleFactor = sunScalePlus; // Scale factor (2 means double the size)
|
||||
const duration = 3000; // Duration of the animation in milliseconds
|
||||
|
||||
// Create a scaling tween
|
||||
this.tweens.add({
|
||||
targets: sun,
|
||||
scaleX: scaleFactor,
|
||||
scaleY: scaleFactor,
|
||||
duration: duration,
|
||||
ease: 'Linear',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const beaniescaleFactor = beanieScalePlus; // Scale factor (2 means double the size)
|
||||
const beanieduration = 2500;
|
||||
this.tweens.add({
|
||||
targets: beanie,
|
||||
scaleX: beaniescaleFactor + 0.004,
|
||||
scaleY: beaniescaleFactor,
|
||||
duration: beanieduration,
|
||||
ease: 'Redial',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const backgroundImages = this.add.image(customWidth / 2, customHeight /2, 'backgroundImage').setDepth(-2).setScale(backgroundScale);
|
||||
this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'letterH').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'letterH').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'animatedH').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
maskGraphics.fillRect(customWidth / 2 - (canvas.width * canvasScale) / 2, customHeight / 2 + canvasHeight - (canvas.height * canvasScale) / 2, canvas.width * canvasScale, canvas.height * canvasScale);
|
||||
const mask = maskGraphics.createGeometryMask();
|
||||
|
||||
|
||||
|
||||
let hideButton = this.add.text(customWidth / 2 - 65, customHeight / 1.1, "Let`s Do", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(customWidth / 2 - 50, customHeight / 1.1, "Help!", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 20;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : H', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
const animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedHHeight, 'animatedH').setDepth(2).setScale(animatedHScale);
|
||||
|
||||
// Play the video
|
||||
animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
||||
// You can set additional properties for the video, such as loop and mute:
|
||||
animatedLetter.setLoop(true); // Loop the video
|
||||
animatedLetter.setMute(false); // Unmute the video
|
||||
animatedLetter.on('complete', function () {
|
||||
// add function after end video;
|
||||
});
|
||||
|
||||
let textX, textY;
|
||||
|
||||
firstLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Tall Down',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
firstLayer.setAlpha(0.5);
|
||||
firstLayer.setInteractive({ draggable: true });
|
||||
|
||||
secondLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer2').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
const secondTextLayer = this.add.text(textX, textY, '2. Tall Down',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioTwoAudio = this.sound.add('audioOne');
|
||||
secondTextLayer.setVisible(false);
|
||||
secondLayer.setDepth(1);
|
||||
secondLayer.setAlpha(0.5);
|
||||
secondLayer.setInteractive({ draggable: true });
|
||||
secondLayer.setVisible(false);
|
||||
|
||||
thirdLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer3').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 3 : customWidth * 0.75;
|
||||
const thirdTextLayer = this.add.text(textX, textY, '3. Slide', { font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioThreeAudio = this.sound.add('audioTwo');
|
||||
thirdTextLayer.setVisible(false);
|
||||
thirdLayer.setDepth(1.1);
|
||||
// thirdLayer.setScale(1.15);
|
||||
thirdLayer.setAlpha(0.5);
|
||||
thirdLayer.setInteractive({ draggable: true });
|
||||
thirdLayer.setVisible(false);
|
||||
|
||||
// Add these variables to keep track of start points
|
||||
let firstDragStartPoint = { x: 0, y: 0 };
|
||||
let secondDragStartPoint = { x: 0, y: 0 };
|
||||
let thirdDragStartPoint = { x: 0, y: 0 };
|
||||
|
||||
// ...
|
||||
|
||||
// Add this code for firstLayer
|
||||
firstLayer.on('dragstart', (pointer) => {
|
||||
firstDragStartPoint.x = pointer.x;
|
||||
firstDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
firstLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(firstDragStartPoint.x, firstDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
|
||||
firstTextLayer.setVisible(false);
|
||||
secondTextLayer.setVisible(true);
|
||||
audioTwoAudio.play();
|
||||
secondLayer.setVisible(true);
|
||||
firstLayer.setAlpha(1);
|
||||
secondLayer.setAlpha(0.5);
|
||||
thirdLayer.setAlpha(0.5);
|
||||
} else {
|
||||
firstLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
secondLayer.on('dragstart', (pointer) => {
|
||||
secondDragStartPoint.x = pointer.x;
|
||||
secondDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
secondLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(secondDragStartPoint.x, secondDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
secondTextLayer.setVisible(false);
|
||||
thirdTextLayer.setVisible(true);
|
||||
audioThreeAudio.play();
|
||||
thirdLayer.setVisible(true);
|
||||
secondLayer.setAlpha(1);
|
||||
thirdLayer.setAlpha(0.5);
|
||||
} else {
|
||||
secondLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
// Add this code for thirdLayer
|
||||
thirdLayer.on('dragstart', (pointer) => {
|
||||
thirdDragStartPoint.x = pointer.x;
|
||||
thirdDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
thirdLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(thirdDragStartPoint.x, thirdDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
thirdLayer.setAlpha(1);
|
||||
thirdTextLayer.setVisible(false);
|
||||
} else {
|
||||
thirdLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
graphics.moveTo(pointer.x, pointer.y);
|
||||
// console.log("Start Position", pointer.x, pointer.y)
|
||||
});
|
||||
|
||||
this.input.on('pointerup', function () {
|
||||
isDrawing = false;
|
||||
});
|
||||
|
||||
this.input.on('pointermove', function (pointer) {
|
||||
if (!isDrawing) return;
|
||||
|
||||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
}
|
||||
|
||||
function update() {
|
||||
}
|
||||
|
||||
</script>
|
||||
350
src/pages/capital-letter/I.astro
Normal file
350
src/pages/capital-letter/I.astro
Normal file
@@ -0,0 +1,350 @@
|
||||
---
|
||||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script is:inline>
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
width: isMobile ? window.innerWidth : window.innerWidth / 2,
|
||||
height: window.innerHeight / 2,
|
||||
};
|
||||
|
||||
const config = {
|
||||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
},
|
||||
scene: {
|
||||
preload: preload,
|
||||
create: create,
|
||||
update: update
|
||||
}
|
||||
};
|
||||
// backgroundImage.png
|
||||
const game = new Phaser.Game(config);
|
||||
const customWidth = window.innerWidth;
|
||||
const customHeight = window.innerHeight;
|
||||
let firstLayer, secondLayer, thirdLayer;
|
||||
let graphics;
|
||||
let isDrawing = false;
|
||||
// let x = 100;
|
||||
|
||||
// // Use x
|
||||
// console.log(x);
|
||||
|
||||
if(isMobile){
|
||||
cloudeSize = 200;
|
||||
cloudHeight = 340;
|
||||
canvasScale = 0.14
|
||||
canvasHeight = 35;
|
||||
letterHeight = 70;
|
||||
letterScale = 1;
|
||||
backgroundScale = 0.8;
|
||||
sunScale = 0.1;
|
||||
sunScalePlus = 0.15;
|
||||
sunWidth = 70;
|
||||
sunHeight = 70;
|
||||
beanieScale = 0.35;
|
||||
beanieScalePlus = 0.365;
|
||||
beanieWidth = 135;
|
||||
beanieHeight = 170;
|
||||
animatedIHeight = 35;
|
||||
animatedIScale = 0.65;
|
||||
} else{
|
||||
cloudeSize = 500;
|
||||
cloudHeight = 250;
|
||||
canvasScale = 0.195;
|
||||
canvasHeight = 20;
|
||||
letterHeight = 50;
|
||||
letterScale = 1;
|
||||
backgroundScale = 1;
|
||||
sunScale = 0.2;
|
||||
sunScalePlus = 0.25;
|
||||
sunWidth = 200;
|
||||
sunHeight = 100;
|
||||
beanieScale = 0.4;
|
||||
beanieScalePlus = 0.45;
|
||||
beanieWidth = 200;
|
||||
beanieHeight = 255;
|
||||
animatedIHeight = 20;
|
||||
animatedIScale = 0.73;
|
||||
}
|
||||
function preload() {
|
||||
this.load.video('animatedI', '/assets/animated-letter/capital_i.mp4');
|
||||
this.load.svg('letterI', '/assets/capital-letter/i.svg');
|
||||
this.load.svg('layer1', '/assets/capital-letter/i_l1.svg');
|
||||
this.load.svg('layer2', '/assets/capital-letter/i_l2.svg');
|
||||
this.load.svg('layer3', '/assets/capital-letter/i_l3.svg');
|
||||
this.load.audio('audioOne', '/assets/audio/tall-down.mp3');
|
||||
this.load.audio('audioTwo', '/assets/audio/slide.mp3');
|
||||
this.load.image('topLogo', '/assets/top_logo.png');
|
||||
this.load.svg('succesImage', '/assets/svg/tick.svg');
|
||||
this.load.svg('hintImage', '/assets/svg/hint.svg');
|
||||
this.load.svg('handPointer', '/assets/svg/hand.svg');
|
||||
this.load.image('backgroundImage', '/assets/bg6.png');
|
||||
this.load.image('cloud', '/assets/cloud.png');
|
||||
this.load.image('canvas', '/assets/canvas4.png');
|
||||
// this.load.image('beanie', '/assets/beanie.png');
|
||||
this.load.image('beanie', '/assets/beanieImage.png');
|
||||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
}
|
||||
|
||||
function create() {
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : I", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
const sun = this.add.sprite(customWidth - sunWidth, sunHeight, 'sun').setScale(sunScale).setDepth(-1.9);
|
||||
const beanie = this.add.sprite(customWidth / 2 - beanieWidth, customHeight / 2 - beanieHeight, 'beanie').setScale(beanieScale).setDepth(1.9);
|
||||
|
||||
|
||||
const scaleFactor = sunScalePlus; // Scale factor (2 means double the size)
|
||||
const duration = 3000; // Duration of the animation in milliseconds
|
||||
|
||||
// Create a scaling tween
|
||||
this.tweens.add({
|
||||
targets: sun,
|
||||
scaleX: scaleFactor,
|
||||
scaleY: scaleFactor,
|
||||
duration: duration,
|
||||
ease: 'Linear',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const beaniescaleFactor = beanieScalePlus; // Scale factor (2 means double the size)
|
||||
const beanieduration = 2500;
|
||||
this.tweens.add({
|
||||
targets: beanie,
|
||||
scaleX: beaniescaleFactor + 0.004,
|
||||
scaleY: beaniescaleFactor,
|
||||
duration: beanieduration,
|
||||
ease: 'Redial',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const backgroundImages = this.add.image(customWidth / 2, customHeight /2, 'backgroundImage').setDepth(-2).setScale(backgroundScale);
|
||||
this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'letterI').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'letterI').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'animatedI').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
maskGraphics.fillRect(customWidth / 2 - (canvas.width * canvasScale) / 2, customHeight / 2 + canvasHeight - (canvas.height * canvasScale) / 2, canvas.width * canvasScale, canvas.height * canvasScale);
|
||||
const mask = maskGraphics.createGeometryMask();
|
||||
|
||||
|
||||
|
||||
let hideButton = this.add.text(customWidth / 2 - 65, customHeight / 1.1, "Let`s Do", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(customWidth / 2 - 50, customHeight / 1.1, "Help!", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 20;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : I', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
const animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedIHeight, 'animatedI').setDepth(2).setScale(animatedIScale);
|
||||
|
||||
// Play the video
|
||||
animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
||||
// You can set additional properties for the video, such as loop and mute:
|
||||
animatedLetter.setLoop(true); // Loop the video
|
||||
animatedLetter.setMute(false); // Unmute the video
|
||||
animatedLetter.on('complete', function () {
|
||||
// add function after end video;
|
||||
});
|
||||
|
||||
let textX, textY;
|
||||
|
||||
firstLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Tall Down',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
firstLayer.setAlpha(0.5);
|
||||
firstLayer.setInteractive({ draggable: true });
|
||||
|
||||
secondLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer2').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
const secondTextLayer = this.add.text(textX, textY, '2. Slide',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioTwoAudio = this.sound.add('audioTwo');
|
||||
secondTextLayer.setVisible(false);
|
||||
secondLayer.setDepth(1);
|
||||
secondLayer.setAlpha(0.5);
|
||||
secondLayer.setInteractive({ draggable: true });
|
||||
secondLayer.setVisible(false);
|
||||
|
||||
thirdLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer3').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 3 : customWidth * 0.75;
|
||||
const thirdTextLayer = this.add.text(textX, textY, '3. Slide', { font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioThreeAudio = this.sound.add('audioTwo');
|
||||
thirdTextLayer.setVisible(false);
|
||||
thirdLayer.setDepth(1.1);
|
||||
// thirdLayer.setScale(1.15);
|
||||
thirdLayer.setAlpha(0.5);
|
||||
thirdLayer.setInteractive({ draggable: true });
|
||||
thirdLayer.setVisible(false);
|
||||
|
||||
// Add these variables to keep track of start points
|
||||
let firstDragStartPoint = { x: 0, y: 0 };
|
||||
let secondDragStartPoint = { x: 0, y: 0 };
|
||||
let thirdDragStartPoint = { x: 0, y: 0 };
|
||||
|
||||
// ...
|
||||
|
||||
// Add this code for firstLayer
|
||||
firstLayer.on('dragstart', (pointer) => {
|
||||
firstDragStartPoint.x = pointer.x;
|
||||
firstDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
firstLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(firstDragStartPoint.x, firstDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
|
||||
firstTextLayer.setVisible(false);
|
||||
secondTextLayer.setVisible(true);
|
||||
audioTwoAudio.play();
|
||||
secondLayer.setVisible(true);
|
||||
firstLayer.setAlpha(1);
|
||||
secondLayer.setAlpha(0.5);
|
||||
thirdLayer.setAlpha(0.5);
|
||||
} else {
|
||||
firstLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
secondLayer.on('dragstart', (pointer) => {
|
||||
secondDragStartPoint.x = pointer.x;
|
||||
secondDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
secondLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(secondDragStartPoint.x, secondDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
secondTextLayer.setVisible(false);
|
||||
thirdTextLayer.setVisible(true);
|
||||
audioThreeAudio.play();
|
||||
thirdLayer.setVisible(true);
|
||||
secondLayer.setAlpha(1);
|
||||
thirdLayer.setAlpha(0.5);
|
||||
} else {
|
||||
secondLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
// Add this code for thirdLayer
|
||||
thirdLayer.on('dragstart', (pointer) => {
|
||||
thirdDragStartPoint.x = pointer.x;
|
||||
thirdDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
thirdLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(thirdDragStartPoint.x, thirdDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
thirdLayer.setAlpha(1);
|
||||
thirdTextLayer.setVisible(false);
|
||||
} else {
|
||||
thirdLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
graphics.moveTo(pointer.x, pointer.y);
|
||||
// console.log("Start Position", pointer.x, pointer.y)
|
||||
});
|
||||
|
||||
this.input.on('pointerup', function () {
|
||||
isDrawing = false;
|
||||
});
|
||||
|
||||
this.input.on('pointermove', function (pointer) {
|
||||
if (!isDrawing) return;
|
||||
|
||||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
}
|
||||
|
||||
function update() {
|
||||
}
|
||||
|
||||
</script>
|
||||
286
src/pages/capital-letter/J.astro
Normal file
286
src/pages/capital-letter/J.astro
Normal file
@@ -0,0 +1,286 @@
|
||||
---
|
||||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script is:inline>
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
width: isMobile ? window.innerWidth : window.innerWidth / 2,
|
||||
height: window.innerHeight / 2,
|
||||
};
|
||||
|
||||
const config = {
|
||||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
},
|
||||
scene: {
|
||||
preload: preload,
|
||||
create: create,
|
||||
update: update
|
||||
}
|
||||
};
|
||||
// backgroundImage.png
|
||||
const game = new Phaser.Game(config);
|
||||
const customWidth = window.innerWidth;
|
||||
const customHeight = window.innerHeight;
|
||||
let firstLayer, secondLayer, thirdLayer;
|
||||
let graphics;
|
||||
let isDrawing = false;
|
||||
|
||||
if(isMobile){
|
||||
cloudeSize = 200;
|
||||
cloudHeight = 340;
|
||||
canvasScale = 0.14
|
||||
canvasHeight = 35;
|
||||
letterHeight = 90;
|
||||
letterScale = 1;
|
||||
backgroundScale = 0.8;
|
||||
sunScale = 0.1;
|
||||
sunScalePlus = 0.15;
|
||||
sunWidth = 70;
|
||||
sunHeight = 70;
|
||||
beanieScale = 0.35;
|
||||
beanieScalePlus = 0.38;
|
||||
beanieWidth = 135;
|
||||
beanieHeight = 170;
|
||||
animatedJHeight = 32;
|
||||
} else{
|
||||
cloudeSize = 500;
|
||||
cloudHeight = 250;
|
||||
canvasScale = 0.195;
|
||||
canvasHeight = 20;
|
||||
letterHeight = 50;
|
||||
letterScale = 1;
|
||||
backgroundScale = 1;
|
||||
sunScale = 0.2;
|
||||
sunScalePlus = 0.25;
|
||||
sunWidth = 200;
|
||||
sunHeight = 100;
|
||||
beanieScale = 0.4;
|
||||
beanieScalePlus = 0.44;
|
||||
beanieWidth = 200;
|
||||
beanieHeight = 245;
|
||||
animatedJHeight = 20;
|
||||
}
|
||||
// let hideButton;
|
||||
|
||||
function preload() {
|
||||
this.load.video('animatedJ', '/assets/animated-letter/capital_j.mp4');
|
||||
this.load.svg('letterJ', '/assets/capital-letter/j.svg');
|
||||
this.load.svg('layer1', '/assets/capital-letter/j.svg');
|
||||
this.load.audio('audioOne', '/assets/audio/tall-hook.mp3');
|
||||
this.load.image('topLogo', '/assets/top_logo.png');
|
||||
this.load.svg('succesImage', '/assets/svg/tick.svg');
|
||||
this.load.svg('hintImage', '/assets/svg/hint.svg');
|
||||
this.load.svg('handPointer', '/assets/svg/hand.svg');
|
||||
this.load.image('backgroundImage', '/assets/bg6.png');
|
||||
this.load.image('cloud', '/assets/cloud.png');
|
||||
this.load.image('canvas', '/assets/canvas4.png');
|
||||
this.load.image('beanie', '/assets/beanieImage.png');
|
||||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
}
|
||||
|
||||
function create() {
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : J", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
// this.add.image(customWidth / 2, 50, 'cloud').setDepth(1.9);
|
||||
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
const sun = this.add.sprite(customWidth - sunWidth, sunHeight, 'sun').setScale(sunScale).setDepth(-1.9);
|
||||
const beanie = this.add.sprite(customWidth / 2 - beanieWidth, customHeight / 2 - beanieHeight, 'beanie').setScale(beanieScale).setDepth(1.9);
|
||||
|
||||
|
||||
const scaleFactor = sunScalePlus; // Scale factor (2 means double the size)
|
||||
const duration = 3000; // Duration of the animation in milliseconds
|
||||
|
||||
// Create a scaling tween
|
||||
this.tweens.add({
|
||||
targets: sun,
|
||||
scaleX: scaleFactor,
|
||||
scaleY: scaleFactor,
|
||||
duration: duration,
|
||||
ease: 'Linear',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const beaniescaleFactor = beanieScalePlus; // Scale factor (2 means double the size)
|
||||
const beanieduration = 2500;
|
||||
this.tweens.add({
|
||||
targets: beanie,
|
||||
scaleX: beaniescaleFactor + 0.004,
|
||||
scaleY: beaniescaleFactor,
|
||||
duration: beanieduration,
|
||||
ease: 'Redial',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const backgroundImages = this.add.image(customWidth / 2, customHeight /2, 'backgroundImage').setDepth(-2).setScale(backgroundScale);
|
||||
this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'letterJ').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2 + 90, customHeight / 2 + letterHeight, 'letterJ').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'animatedJ').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
maskGraphics.fillRect(customWidth / 2 - (canvas.width * canvasScale) / 2, customHeight / 2 + canvasHeight - (canvas.height * canvasScale) / 2, canvas.width * canvasScale, canvas.height * canvasScale);
|
||||
const mask = maskGraphics.createGeometryMask();
|
||||
|
||||
|
||||
|
||||
let hideButton = this.add.text(customWidth / 2 - 65, customHeight / 1.1, "Let`s Do", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(customWidth / 2 - 50, customHeight / 1.1, "Help!", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 20;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : J', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
const animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedJHeight, 'animatedJ').setDepth(2).setScale(0.73);
|
||||
|
||||
// Play the video
|
||||
animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
||||
// You can set additional properties for the video, such as loop and mute:
|
||||
animatedLetter.setLoop(true); // Loop the video
|
||||
animatedLetter.setMute(false); // Unmute the video
|
||||
animatedLetter.on('complete', function () {
|
||||
// Video playback is complete
|
||||
// You can add your code here for what to do when the video finishes.
|
||||
});
|
||||
|
||||
let textX, textY;
|
||||
|
||||
firstLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Tall Hook',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
firstLayer.setAlpha(0.5);
|
||||
firstLayer.setInteractive({ draggable: true });
|
||||
|
||||
|
||||
|
||||
// Add these variables to keep track of start points
|
||||
let firstDragStartPoint = { x: 0, y: 0 };
|
||||
|
||||
// ...
|
||||
|
||||
// Add this code for firstLayer
|
||||
firstLayer.on('dragstart', (pointer) => {
|
||||
firstDragStartPoint.x = pointer.x;
|
||||
firstDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
firstLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(firstDragStartPoint.x, firstDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 50) {
|
||||
|
||||
firstTextLayer.setVisible(false);
|
||||
firstLayer.setAlpha(1);
|
||||
} else {
|
||||
firstLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
graphics.moveTo(pointer.x, pointer.y);
|
||||
});
|
||||
|
||||
this.input.on('pointerup', function () {
|
||||
isDrawing = false;
|
||||
});
|
||||
|
||||
this.input.on('pointermove', function (pointer) {
|
||||
if (!isDrawing) return;
|
||||
|
||||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
350
src/pages/capital-letter/K.astro
Normal file
350
src/pages/capital-letter/K.astro
Normal file
@@ -0,0 +1,350 @@
|
||||
---
|
||||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script is:inline>
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
width: isMobile ? window.innerWidth : window.innerWidth / 2,
|
||||
height: window.innerHeight / 2,
|
||||
};
|
||||
|
||||
const config = {
|
||||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
},
|
||||
scene: {
|
||||
preload: preload,
|
||||
create: create,
|
||||
update: update
|
||||
}
|
||||
};
|
||||
// backgroundImage.png
|
||||
const game = new Phaser.Game(config);
|
||||
const customWidth = window.innerWidth;
|
||||
const customHeight = window.innerHeight;
|
||||
let firstLayer, secondLayer, thirdLayer;
|
||||
let graphics;
|
||||
let isDrawing = false;
|
||||
// let x = 100;
|
||||
|
||||
// // Use x
|
||||
// console.log(x);
|
||||
|
||||
if(isMobile){
|
||||
cloudeSize = 200;
|
||||
cloudHeight = 340;
|
||||
canvasScale = 0.14
|
||||
canvasHeight = 35;
|
||||
letterHeight = 70;
|
||||
letterScale = 1;
|
||||
backgroundScale = 0.8;
|
||||
sunScale = 0.1;
|
||||
sunScalePlus = 0.15;
|
||||
sunWidth = 70;
|
||||
sunHeight = 70;
|
||||
beanieScale = 0.35;
|
||||
beanieScalePlus = 0.365;
|
||||
beanieWidth = 135;
|
||||
beanieHeight = 170;
|
||||
animatedKHeight = 35;
|
||||
animatedKScale = 0.65;
|
||||
} else{
|
||||
cloudeSize = 500;
|
||||
cloudHeight = 250;
|
||||
canvasScale = 0.195;
|
||||
canvasHeight = 20;
|
||||
letterHeight = 50;
|
||||
letterScale = 1;
|
||||
backgroundScale = 1;
|
||||
sunScale = 0.2;
|
||||
sunScalePlus = 0.25;
|
||||
sunWidth = 200;
|
||||
sunHeight = 100;
|
||||
beanieScale = 0.4;
|
||||
beanieScalePlus = 0.45;
|
||||
beanieWidth = 200;
|
||||
beanieHeight = 255;
|
||||
animatedKHeight = 20;
|
||||
animatedKScale = 0.73;
|
||||
}
|
||||
function preload() {
|
||||
this.load.video('animatedK', '/assets/animated-letter/capital_k.mp4');
|
||||
this.load.svg('letterK', '/assets/capital-letter/k.svg');
|
||||
this.load.svg('layer1', '/assets/capital-letter/k_l1.svg');
|
||||
this.load.svg('layer2', '/assets/capital-letter/k_l2.svg');
|
||||
this.load.svg('layer3', '/assets/capital-letter/k_l3.svg');
|
||||
this.load.audio('audioOne', '/assets/audio/tall-down.mp3');
|
||||
this.load.audio('audioTwo', '/assets/audio/slant.mp3');
|
||||
this.load.image('topLogo', '/assets/top_logo.png');
|
||||
this.load.svg('succesImage', '/assets/svg/tick.svg');
|
||||
this.load.svg('hintImage', '/assets/svg/hint.svg');
|
||||
this.load.svg('handPointer', '/assets/svg/hand.svg');
|
||||
this.load.image('backgroundImage', '/assets/bg6.png');
|
||||
this.load.image('cloud', '/assets/cloud.png');
|
||||
this.load.image('canvas', '/assets/canvas4.png');
|
||||
// this.load.image('beanie', '/assets/beanie.png');
|
||||
this.load.image('beanie', '/assets/beanieImage.png');
|
||||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
}
|
||||
|
||||
function create() {
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : K", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
const sun = this.add.sprite(customWidth - sunWidth, sunHeight, 'sun').setScale(sunScale).setDepth(-1.9);
|
||||
const beanie = this.add.sprite(customWidth / 2 - beanieWidth, customHeight / 2 - beanieHeight, 'beanie').setScale(beanieScale).setDepth(1.9);
|
||||
|
||||
|
||||
const scaleFactor = sunScalePlus; // Scale factor (2 means double the size)
|
||||
const duration = 3000; // Duration of the animation in milliseconds
|
||||
|
||||
// Create a scaling tween
|
||||
this.tweens.add({
|
||||
targets: sun,
|
||||
scaleX: scaleFactor,
|
||||
scaleY: scaleFactor,
|
||||
duration: duration,
|
||||
ease: 'Linear',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const beaniescaleFactor = beanieScalePlus; // Scale factor (2 means double the size)
|
||||
const beanieduration = 2500;
|
||||
this.tweens.add({
|
||||
targets: beanie,
|
||||
scaleX: beaniescaleFactor + 0.004,
|
||||
scaleY: beaniescaleFactor,
|
||||
duration: beanieduration,
|
||||
ease: 'Redial',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const backgroundImages = this.add.image(customWidth / 2, customHeight /2, 'backgroundImage').setDepth(-2).setScale(backgroundScale);
|
||||
this.add.image(customWidth / 2 + 50, customHeight / 2 + letterHeight, 'letterK').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'letterK').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'animatedK').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
maskGraphics.fillRect(customWidth / 2 - (canvas.width * canvasScale) / 2, customHeight / 2 + canvasHeight - (canvas.height * canvasScale) / 2, canvas.width * canvasScale, canvas.height * canvasScale);
|
||||
const mask = maskGraphics.createGeometryMask();
|
||||
|
||||
|
||||
|
||||
let hideButton = this.add.text(customWidth / 2 - 65, customHeight / 1.1, "Let`s Do", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(customWidth / 2 - 50, customHeight / 1.1, "Help!", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 20;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : K', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
const animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedKHeight, 'animatedK').setDepth(2).setScale(animatedKScale);
|
||||
|
||||
// Play the video
|
||||
animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
||||
// You can set additional properties for the video, such as loop and mute:
|
||||
animatedLetter.setLoop(true); // Loop the video
|
||||
animatedLetter.setMute(false); // Unmute the video
|
||||
animatedLetter.on('complete', function () {
|
||||
// add function after end video;
|
||||
});
|
||||
|
||||
let textX, textY;
|
||||
|
||||
firstLayer = this.add.image(customWidth / 2 + 50, customHeight / 2 + letterHeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Tall Down',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
firstLayer.setAlpha(0.5);
|
||||
firstLayer.setInteractive({ draggable: true });
|
||||
|
||||
secondLayer = this.add.image(customWidth / 2 + 50, customHeight / 2 + letterHeight, 'layer2').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
const secondTextLayer = this.add.text(textX, textY, '2. Slant',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioTwoAudio = this.sound.add('audioTwo');
|
||||
secondTextLayer.setVisible(false);
|
||||
secondLayer.setDepth(1);
|
||||
secondLayer.setAlpha(0.5);
|
||||
secondLayer.setInteractive({ draggable: true });
|
||||
secondLayer.setVisible(false);
|
||||
|
||||
thirdLayer = this.add.image(customWidth / 2 + 50, customHeight / 2 + letterHeight, 'layer3').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 3 : customWidth * 0.75;
|
||||
const thirdTextLayer = this.add.text(textX, textY, '3. Slant', { font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioThreeAudio = this.sound.add('audioTwo');
|
||||
thirdTextLayer.setVisible(false);
|
||||
thirdLayer.setDepth(1.1);
|
||||
// thirdLayer.setScale(1.15);
|
||||
thirdLayer.setAlpha(0.5);
|
||||
thirdLayer.setInteractive({ draggable: true });
|
||||
thirdLayer.setVisible(false);
|
||||
|
||||
// Add these variables to keep track of start points
|
||||
let firstDragStartPoint = { x: 0, y: 0 };
|
||||
let secondDragStartPoint = { x: 0, y: 0 };
|
||||
let thirdDragStartPoint = { x: 0, y: 0 };
|
||||
|
||||
// ...
|
||||
|
||||
// Add this code for firstLayer
|
||||
firstLayer.on('dragstart', (pointer) => {
|
||||
firstDragStartPoint.x = pointer.x;
|
||||
firstDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
firstLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(firstDragStartPoint.x, firstDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
|
||||
firstTextLayer.setVisible(false);
|
||||
secondTextLayer.setVisible(true);
|
||||
audioTwoAudio.play();
|
||||
secondLayer.setVisible(true);
|
||||
firstLayer.setAlpha(1);
|
||||
secondLayer.setAlpha(0.5);
|
||||
thirdLayer.setAlpha(0.5);
|
||||
} else {
|
||||
firstLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
secondLayer.on('dragstart', (pointer) => {
|
||||
secondDragStartPoint.x = pointer.x;
|
||||
secondDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
secondLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(secondDragStartPoint.x, secondDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
secondTextLayer.setVisible(false);
|
||||
thirdTextLayer.setVisible(true);
|
||||
audioThreeAudio.play();
|
||||
thirdLayer.setVisible(true);
|
||||
secondLayer.setAlpha(1);
|
||||
thirdLayer.setAlpha(0.5);
|
||||
} else {
|
||||
secondLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
// Add this code for thirdLayer
|
||||
thirdLayer.on('dragstart', (pointer) => {
|
||||
thirdDragStartPoint.x = pointer.x;
|
||||
thirdDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
thirdLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(thirdDragStartPoint.x, thirdDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
thirdLayer.setAlpha(1);
|
||||
thirdTextLayer.setVisible(false);
|
||||
} else {
|
||||
thirdLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
graphics.moveTo(pointer.x, pointer.y);
|
||||
// console.log("Start Position", pointer.x, pointer.y)
|
||||
});
|
||||
|
||||
this.input.on('pointerup', function () {
|
||||
isDrawing = false;
|
||||
});
|
||||
|
||||
this.input.on('pointermove', function (pointer) {
|
||||
if (!isDrawing) return;
|
||||
|
||||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
}
|
||||
|
||||
function update() {
|
||||
}
|
||||
|
||||
</script>
|
||||
319
src/pages/capital-letter/L.astro
Normal file
319
src/pages/capital-letter/L.astro
Normal file
@@ -0,0 +1,319 @@
|
||||
---
|
||||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script is:inline>
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
width: isMobile ? window.innerWidth : window.innerWidth / 2,
|
||||
height: window.innerHeight / 2,
|
||||
};
|
||||
|
||||
const config = {
|
||||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
},
|
||||
scene: {
|
||||
preload: preload,
|
||||
create: create,
|
||||
update: update
|
||||
}
|
||||
};
|
||||
// backgroundImage.png
|
||||
const game = new Phaser.Game(config);
|
||||
const customWidth = window.innerWidth;
|
||||
const customHeight = window.innerHeight;
|
||||
let firstLayer, secondLayer;
|
||||
let graphics;
|
||||
let isDrawing = false;
|
||||
|
||||
if(isMobile){
|
||||
cloudeSize = 200;
|
||||
cloudHeight = 340;
|
||||
canvasScale = 0.14
|
||||
canvasHeight = 35;
|
||||
letterHeight = 58;
|
||||
letterScale = 0.85;
|
||||
backgroundScale = 0.8;
|
||||
sunScale = 0.1;
|
||||
sunScalePlus = 0.15;
|
||||
sunWidth = 70;
|
||||
sunHeight = 70;
|
||||
beanieScale = 0.35;
|
||||
beanieScalePlus = 0.38;
|
||||
beanieWidth = 135;
|
||||
beanieHeight = 170;
|
||||
animatedLHeight = 32;
|
||||
} else{
|
||||
cloudeSize = 500;
|
||||
cloudHeight = 250;
|
||||
canvasScale = 0.195;
|
||||
canvasHeight = 20;
|
||||
letterHeight = 50;
|
||||
letterScale = 1;
|
||||
backgroundScale = 1;
|
||||
sunScale = 0.2;
|
||||
sunScalePlus = 0.25;
|
||||
sunWidth = 200;
|
||||
sunHeight = 100;
|
||||
beanieScale = 0.4;
|
||||
beanieScalePlus = 0.44;
|
||||
beanieWidth = 200;
|
||||
beanieHeight = 245;
|
||||
animatedLHeight = 20;
|
||||
}
|
||||
// let hideButton;
|
||||
|
||||
function preload() {
|
||||
this.load.video('animatedL', '/assets/animated-letter/capital_l.mp4');
|
||||
this.load.svg('letterL', '/assets/capital-letter/l.svg');
|
||||
this.load.svg('layer1', '/assets/capital-letter/l_l1.svg');
|
||||
this.load.svg('layer2', '/assets/capital-letter/l_l2.svg');
|
||||
this.load.audio('audioOne', '/assets/audio/tall-down.mp3');
|
||||
this.load.audio('audioTwo', '/assets/audio/slide.mp3');
|
||||
this.load.image('topLogo', '/assets/top_logo.png');
|
||||
this.load.svg('succesImage', '/assets/svg/tick.svg');
|
||||
this.load.svg('hintImage', '/assets/svg/hint.svg');
|
||||
this.load.svg('handPointer', '/assets/svg/hand.svg');
|
||||
this.load.image('backgroundImage', '/assets/bg6.png');
|
||||
this.load.image('cloud', '/assets/cloud.png');
|
||||
this.load.image('canvas', '/assets/canvas4.png');
|
||||
this.load.image('beanie', '/assets/beanieImage.png');
|
||||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
}
|
||||
|
||||
function create() {
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : L", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
// this.add.image(customWidth / 2, 50, 'cloud').setDepth(1.9);
|
||||
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
const sun = this.add.sprite(customWidth - sunWidth, sunHeight, 'sun').setScale(sunScale).setDepth(-1.9);
|
||||
const beanie = this.add.sprite(customWidth / 2 - beanieWidth, customHeight / 2 - beanieHeight, 'beanie').setScale(beanieScale).setDepth(1.9);
|
||||
|
||||
|
||||
const scaleFactor = sunScalePlus; // Scale factor (2 means double the size)
|
||||
const duration = 3000; // Duration of the animation in milliseconds
|
||||
|
||||
// Create a scaling tween
|
||||
this.tweens.add({
|
||||
targets: sun,
|
||||
scaleX: scaleFactor,
|
||||
scaleY: scaleFactor,
|
||||
duration: duration,
|
||||
ease: 'Linear',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const beaniescaleFactor = beanieScalePlus; // Scale factor (2 means double the size)
|
||||
const beanieduration = 2500;
|
||||
this.tweens.add({
|
||||
targets: beanie,
|
||||
scaleX: beaniescaleFactor + 0.004,
|
||||
scaleY: beaniescaleFactor,
|
||||
duration: beanieduration,
|
||||
ease: 'Redial',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const backgroundImages = this.add.image(customWidth / 2, customHeight /2, 'backgroundImage').setDepth(-2).setScale(backgroundScale);
|
||||
this.add.image(customWidth / 2 - 30, customHeight / 2 + letterHeight, 'letterL').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2 - 30, customHeight / 2 + letterHeight, 'letterL').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'animatedL').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
maskGraphics.fillRect(customWidth / 2 - (canvas.width * canvasScale) / 2, customHeight / 2 + canvasHeight - (canvas.height * canvasScale) / 2, canvas.width * canvasScale, canvas.height * canvasScale);
|
||||
const mask = maskGraphics.createGeometryMask();
|
||||
|
||||
|
||||
|
||||
let hideButton = this.add.text(customWidth / 2 - 65, customHeight / 1.1, "Let`s Do", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(customWidth / 2 - 50, customHeight / 1.1, "Help!", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 20;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : L', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
const animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedLHeight, 'animatedL').setDepth(2).setScale(0.73);
|
||||
|
||||
// Play the video
|
||||
animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
||||
// You can set additional properties for the video, such as loop and mute:
|
||||
animatedLetter.setLoop(true); // Loop the video
|
||||
animatedLetter.setMute(false); // Unmute the video
|
||||
animatedLetter.on('complete', function () {
|
||||
// Video playback is complete
|
||||
// You can add your code here for what to do when the video finishes.
|
||||
});
|
||||
|
||||
let textX, textY;
|
||||
|
||||
firstLayer = this.add.image(customWidth / 2 - 30, customHeight / 2 + letterHeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Tall Down',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
firstLayer.setAlpha(0.5);
|
||||
firstLayer.setInteractive({ draggable: true });
|
||||
|
||||
secondLayer = this.add.image(customWidth / 2 - 30, customHeight / 2 + letterHeight, 'layer2').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
const secondTextLayer = this.add.text(textX, textY, '2. Slide',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioTwoAudio = this.sound.add('audioTwo');
|
||||
secondTextLayer.setVisible(false);
|
||||
secondLayer.setDepth(1);
|
||||
secondLayer.setAlpha(0.5);
|
||||
secondLayer.setInteractive({ draggable: true });
|
||||
secondLayer.setVisible(false);
|
||||
|
||||
|
||||
// Add these variables to keep track of start points
|
||||
let firstDragStartPoint = { x: 0, y: 0 };
|
||||
let secondDragStartPoint = { x: 0, y: 0 };
|
||||
|
||||
// ...
|
||||
|
||||
// Add this code for firstLayer
|
||||
firstLayer.on('dragstart', (pointer) => {
|
||||
firstDragStartPoint.x = pointer.x;
|
||||
firstDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
firstLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(firstDragStartPoint.x, firstDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
|
||||
firstTextLayer.setVisible(false);
|
||||
secondTextLayer.setVisible(true);
|
||||
audioTwoAudio.play();
|
||||
secondLayer.setVisible(true);
|
||||
firstLayer.setAlpha(1);
|
||||
secondLayer.setAlpha(0.5);
|
||||
} else {
|
||||
firstLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
``
|
||||
// Repeat the above code for secondLayer and thirdLayer
|
||||
|
||||
// Add this code for secondLayer
|
||||
secondLayer.on('dragstart', (pointer) => {
|
||||
secondDragStartPoint.x = pointer.x;
|
||||
secondDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
secondLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(secondDragStartPoint.x, secondDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >=100) {
|
||||
secondTextLayer.setVisible(false);
|
||||
secondLayer.setAlpha(1);
|
||||
} else {
|
||||
secondLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
graphics.moveTo(pointer.x, pointer.y);
|
||||
console.log("Start Position", pointer.x, pointer.y)
|
||||
});
|
||||
|
||||
this.input.on('pointerup', function () {
|
||||
isDrawing = false;
|
||||
});
|
||||
|
||||
this.input.on('pointermove', function (pointer) {
|
||||
if (!isDrawing) return;
|
||||
|
||||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
386
src/pages/capital-letter/M.astro
Normal file
386
src/pages/capital-letter/M.astro
Normal file
@@ -0,0 +1,386 @@
|
||||
---
|
||||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script is:inline>
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
width: isMobile ? window.innerWidth : window.innerWidth / 2,
|
||||
height: window.innerHeight / 2,
|
||||
};
|
||||
|
||||
const config = {
|
||||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
},
|
||||
scene: {
|
||||
preload: preload,
|
||||
create: create,
|
||||
update: update
|
||||
}
|
||||
};
|
||||
// backgroundImage.png
|
||||
const game = new Phaser.Game(config);
|
||||
const customWidth = window.innerWidth;
|
||||
const customHeight = window.innerHeight;
|
||||
let firstLayer, secondLayer, thirdLayer, fourthLayer;
|
||||
let graphics;
|
||||
let isDrawing = false;
|
||||
|
||||
if(isMobile){
|
||||
cloudeSize = 200;
|
||||
cloudHeight = 340;
|
||||
canvasScale = 0.14
|
||||
canvasHeight = 35;
|
||||
letterHeight = 60;
|
||||
letterScale = 0.85;
|
||||
backgroundScale = 0.8;
|
||||
sunScale = 0.1;
|
||||
sunScalePlus = 0.15;
|
||||
sunWidth = 70;
|
||||
sunHeight = 70;
|
||||
beanieScale = 0.35;
|
||||
beanieScalePlus = 0.38;
|
||||
beanieWidth = 135;
|
||||
beanieHeight = 170;
|
||||
animatedMHeight = 32;
|
||||
} else{
|
||||
cloudeSize = 500;
|
||||
cloudHeight = 250;
|
||||
canvasScale = 0.195;
|
||||
canvasHeight = 20;
|
||||
letterHeight = 50;
|
||||
letterScale = 1;
|
||||
backgroundScale = 1;
|
||||
sunScale = 0.2;
|
||||
sunScalePlus = 0.25;
|
||||
sunWidth = 200;
|
||||
sunHeight = 100;
|
||||
beanieScale = 0.4;
|
||||
beanieScalePlus = 0.44;
|
||||
beanieWidth = 200;
|
||||
beanieHeight = 245;
|
||||
animatedMHeight = 20;
|
||||
}
|
||||
function preload() {
|
||||
this.load.video('animatedM', '/assets/animated-letter/capital_m.mp4');
|
||||
this.load.svg('letterM', '/assets/capital-letter/m.svg');
|
||||
this.load.svg('layer1', '/assets/capital-letter/m_l1.svg');
|
||||
this.load.svg('layer2', '/assets/capital-letter/m_l2.svg');
|
||||
this.load.svg('layer3', '/assets/capital-letter/m_l3.svg');
|
||||
this.load.svg('layer4', '/assets/capital-letter/m_l4.svg');
|
||||
this.load.audio('audioOne', '/assets/audio/tall-down.mp3');
|
||||
this.load.audio('audioTwo', '/assets/audio/slant.mp3');
|
||||
this.load.image('topLogo', '/assets/top_logo.png');
|
||||
this.load.svg('succesImage', '/assets/svg/tick.svg');
|
||||
this.load.svg('hintImage', '/assets/svg/hint.svg');
|
||||
this.load.svg('handPointer', '/assets/svg/hand.svg');
|
||||
this.load.image('backgroundImage', '/assets/bg6.png');
|
||||
this.load.image('cloud', '/assets/cloud.png');
|
||||
this.load.image('canvas', '/assets/canvas4.png');
|
||||
this.load.image('beanie', '/assets/beanieImage.png');
|
||||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
}
|
||||
|
||||
function create() {
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : M", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
// this.add.image(customWidth / 2, 50, 'cloud').setDepth(1.9);
|
||||
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
const sun = this.add.sprite(customWidth - sunWidth, sunHeight, 'sun').setScale(sunScale).setDepth(-1.9);
|
||||
const beanie = this.add.sprite(customWidth / 2 - beanieWidth, customHeight / 2 - beanieHeight, 'beanie').setScale(beanieScale).setDepth(1.9);
|
||||
|
||||
|
||||
const scaleFactor = sunScalePlus; // Scale factor (2 means double the size)
|
||||
const duration = 3000; // Duration of the animation in milliseconds
|
||||
|
||||
// Create a scaling tween
|
||||
this.tweens.add({
|
||||
targets: sun,
|
||||
scaleX: scaleFactor,
|
||||
scaleY: scaleFactor,
|
||||
duration: duration,
|
||||
ease: 'Linear',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const beaniescaleFactor = beanieScalePlus; // Scale factor (2 means double the size)
|
||||
const beanieduration = 2500;
|
||||
this.tweens.add({
|
||||
targets: beanie,
|
||||
scaleX: beaniescaleFactor + 0.004,
|
||||
scaleY: beaniescaleFactor,
|
||||
duration: beanieduration,
|
||||
ease: 'Redial',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const backgroundImages = this.add.image(customWidth / 2, customHeight /2, 'backgroundImage').setDepth(-2).setScale(backgroundScale);
|
||||
this.add.image(customWidth / 2 - 20, customHeight / 2 + letterHeight, 'letterM').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2 - 20, customHeight / 2 + letterHeight, 'letterM').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'animatedM').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
maskGraphics.fillRect(customWidth / 2 - (canvas.width * canvasScale) / 2, customHeight / 2 + canvasHeight - (canvas.height * canvasScale) / 2, canvas.width * canvasScale, canvas.height * canvasScale);
|
||||
const mask = maskGraphics.createGeometryMask();
|
||||
|
||||
|
||||
|
||||
let hideButton = this.add.text(customWidth / 2 - 65, customHeight / 1.1, "Let`s Do", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(customWidth / 2 - 50, customHeight / 1.1, "Help!", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 20;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : M', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
const animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedMHeight, 'animatedM').setDepth(2).setScale(0.73);
|
||||
|
||||
// Play the video
|
||||
animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
||||
// You can set additional properties for the video, such as loop and mute:
|
||||
animatedLetter.setLoop(true); // Loop the video
|
||||
animatedLetter.setMute(false); // Unmute the video
|
||||
animatedLetter.on('complete', function () {
|
||||
// Video playback is complete
|
||||
// You can add your code here for what to do when the video finishes.
|
||||
});
|
||||
|
||||
let textX, textY;
|
||||
|
||||
firstLayer = this.add.image(customWidth / 2 - 20, customHeight / 2 + letterHeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Tall Down',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
firstLayer.setAlpha(0.5);
|
||||
firstLayer.setInteractive({ draggable: true });
|
||||
|
||||
secondLayer = this.add.image(customWidth / 2 - 20, customHeight / 2 + letterHeight, 'layer2').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
const secondTextLayer = this.add.text(textX, textY, '2. Tall Down',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioTwoAudio = this.sound.add('audioOne');
|
||||
secondTextLayer.setVisible(false);
|
||||
secondLayer.setDepth(1);
|
||||
secondLayer.setAlpha(0.5);
|
||||
secondLayer.setInteractive({ draggable: true });
|
||||
secondLayer.setVisible(false);
|
||||
|
||||
thirdLayer = this.add.image(customWidth / 2 - 20, customHeight / 2 + letterHeight, 'layer3').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 3 : customWidth * 0.75;
|
||||
const thirdTextLayer = this.add.text(textX, textY, '3. Slant', { font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioThreeAudio = this.sound.add('audioTwo');
|
||||
thirdTextLayer.setVisible(false);
|
||||
thirdLayer.setDepth(1.1);
|
||||
// thirdLayer.setScale(1.15);
|
||||
thirdLayer.setAlpha(0.5);
|
||||
thirdLayer.setInteractive({ draggable: true });
|
||||
thirdLayer.setVisible(false);
|
||||
|
||||
fourthLayer = this.add.image(customWidth / 2 - 20, customHeight / 2 + letterHeight, 'layer4').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 3 : customWidth * 0.75;
|
||||
const fourthTextLayer = this.add.text(textX, textY, '4. Slant', { font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioFourthAudio = this.sound.add('audioTwo');
|
||||
fourthTextLayer.setVisible(false);
|
||||
fourthLayer.setDepth(1.1);
|
||||
// fourthLayer.setScale(1.15);
|
||||
fourthLayer.setAlpha(0.5);
|
||||
fourthLayer.setInteractive({ draggable: true });
|
||||
fourthLayer.setVisible(false);
|
||||
|
||||
// Add these variables to keep track of start points
|
||||
let firstDragStartPoint = { x: 0, y: 0 };
|
||||
let secondDragStartPoint = { x: 0, y: 0 };
|
||||
let thirdDragStartPoint = { x: 0, y: 0 };
|
||||
let fourthDragStartPoint = { x: 0, y: 0 };
|
||||
|
||||
// Add this code for firstLayer
|
||||
firstLayer.on('dragstart', (pointer) => {
|
||||
firstDragStartPoint.x = pointer.x;
|
||||
firstDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
firstLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(firstDragStartPoint.x, firstDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
firstTextLayer.setVisible(false);
|
||||
secondTextLayer.setVisible(true);
|
||||
audioTwoAudio.play();
|
||||
secondLayer.setVisible(true);
|
||||
firstLayer.setAlpha(1);
|
||||
secondLayer.setAlpha(0.5);
|
||||
thirdLayer.setAlpha(0.5);
|
||||
fourthLayer.setAlpha(0.5);
|
||||
} else {
|
||||
firstLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
// Repeat the above code for secondLayer and thirdLayer
|
||||
|
||||
// Add this code for secondLayer
|
||||
secondLayer.on('dragstart', (pointer) => {
|
||||
secondDragStartPoint.x = pointer.x;
|
||||
secondDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
secondLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(secondDragStartPoint.x, secondDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
secondTextLayer.setVisible(false);
|
||||
thirdTextLayer.setVisible(true);
|
||||
audioThreeAudio.play();
|
||||
thirdLayer.setVisible(true);
|
||||
secondLayer.setAlpha(1);
|
||||
thirdLayer.setAlpha(0.5);
|
||||
fourthLayer.setAlpha(0.5);
|
||||
} else {
|
||||
secondLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
// Add this code for thirdLayer
|
||||
thirdLayer.on('dragstart', (pointer) => {
|
||||
thirdDragStartPoint.x = pointer.x;
|
||||
thirdDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
thirdLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(thirdDragStartPoint.x, thirdDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
thirdLayer.setAlpha(1);
|
||||
thirdTextLayer.setVisible(false);
|
||||
fourthTextLayer.setVisible(true);
|
||||
fourthLayer.setVisible(true);
|
||||
fourthLayer.setAlpha(0.5);
|
||||
audioFourthAudio.play();
|
||||
} else {
|
||||
thirdLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
fourthLayer.on('dragstart', (pointer) => {
|
||||
fourthDragStartPoint.x = pointer.x;
|
||||
fourthDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
fourthLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(fourthDragStartPoint.x, fourthDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
fourthLayer.setAlpha(1);
|
||||
fourthTextLayer.setVisible(false);
|
||||
} else {
|
||||
fourthLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
graphics.moveTo(pointer.x, pointer.y);
|
||||
console.log("Start Position", pointer.x, pointer.y)
|
||||
});
|
||||
|
||||
this.input.on('pointerup', function () {
|
||||
isDrawing = false;
|
||||
});
|
||||
|
||||
this.input.on('pointermove', function (pointer) {
|
||||
if (!isDrawing) return;
|
||||
|
||||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
|
||||
// Start Position 626 317
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
351
src/pages/capital-letter/N.astro
Normal file
351
src/pages/capital-letter/N.astro
Normal file
@@ -0,0 +1,351 @@
|
||||
---
|
||||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script is:inline>
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
width: isMobile ? window.innerWidth : window.innerWidth / 2,
|
||||
height: window.innerHeight / 2,
|
||||
};
|
||||
|
||||
const config = {
|
||||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
},
|
||||
scene: {
|
||||
preload: preload,
|
||||
create: create,
|
||||
update: update
|
||||
}
|
||||
};
|
||||
// backgroundImage.png
|
||||
const game = new Phaser.Game(config);
|
||||
const customWidth = window.innerWidth;
|
||||
const customHeight = window.innerHeight;
|
||||
let firstLayer, secondLayer, thirdLayer;
|
||||
let graphics;
|
||||
let isDrawing = false;
|
||||
// let x = 100;
|
||||
|
||||
// // Use x
|
||||
// console.log(x);
|
||||
|
||||
if(isMobile){
|
||||
cloudeSize = 200;
|
||||
cloudHeight = 340;
|
||||
canvasScale = 0.14
|
||||
canvasHeight = 35;
|
||||
letterHeight = 70;
|
||||
letterScale = 1;
|
||||
backgroundScale = 0.8;
|
||||
sunScale = 0.1;
|
||||
sunScalePlus = 0.15;
|
||||
sunWidth = 70;
|
||||
sunHeight = 70;
|
||||
beanieScale = 0.35;
|
||||
beanieScalePlus = 0.365;
|
||||
beanieWidth = 135;
|
||||
beanieHeight = 170;
|
||||
animatedNHeight = 35;
|
||||
animatedNScale = 0.65;
|
||||
} else{
|
||||
cloudeSize = 500;
|
||||
cloudHeight = 250;
|
||||
canvasScale = 0.195;
|
||||
canvasHeight = 20;
|
||||
letterHeight = 50;
|
||||
letterScale = 1;
|
||||
backgroundScale = 1;
|
||||
sunScale = 0.2;
|
||||
sunScalePlus = 0.25;
|
||||
sunWidth = 200;
|
||||
sunHeight = 100;
|
||||
beanieScale = 0.4;
|
||||
beanieScalePlus = 0.45;
|
||||
beanieWidth = 200;
|
||||
beanieHeight = 255;
|
||||
animatedNHeight = 20;
|
||||
animatedNScale = 0.73;
|
||||
}
|
||||
function preload() {
|
||||
this.load.video('animatedN', '/assets/animated-letter/capital_n.mp4');
|
||||
this.load.svg('letterN', '/assets/capital-letter/n.svg');
|
||||
this.load.svg('layer1', '/assets/capital-letter/n_l1.svg');
|
||||
this.load.svg('layer2', '/assets/capital-letter/n_l2.svg');
|
||||
this.load.svg('layer3', '/assets/capital-letter/n_l3.svg');
|
||||
this.load.audio('audioOne', '/assets/audio/tall-down.mp3');
|
||||
this.load.audio('audioTwo', '/assets/audio/slant.mp3');
|
||||
this.load.audio('audioThree', '/assets/audio/slide.mp3');
|
||||
this.load.image('topLogo', '/assets/top_logo.png');
|
||||
this.load.svg('succesImage', '/assets/svg/tick.svg');
|
||||
this.load.svg('hintImage', '/assets/svg/hint.svg');
|
||||
this.load.svg('handPointer', '/assets/svg/hand.svg');
|
||||
this.load.image('backgroundImage', '/assets/bg6.png');
|
||||
this.load.image('cloud', '/assets/cloud.png');
|
||||
this.load.image('canvas', '/assets/canvas4.png');
|
||||
// this.load.image('beanie', '/assets/beanie.png');
|
||||
this.load.image('beanie', '/assets/beanieImage.png');
|
||||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
}
|
||||
|
||||
function create() {
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : N", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
const sun = this.add.sprite(customWidth - sunWidth, sunHeight, 'sun').setScale(sunScale).setDepth(-1.9);
|
||||
const beanie = this.add.sprite(customWidth / 2 - beanieWidth, customHeight / 2 - beanieHeight, 'beanie').setScale(beanieScale).setDepth(1.9);
|
||||
|
||||
|
||||
const scaleFactor = sunScalePlus; // Scale factor (2 means double the size)
|
||||
const duration = 3000; // Duration of the animation in milliseconds
|
||||
|
||||
// Create a scaling tween
|
||||
this.tweens.add({
|
||||
targets: sun,
|
||||
scaleX: scaleFactor,
|
||||
scaleY: scaleFactor,
|
||||
duration: duration,
|
||||
ease: 'Linear',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const beaniescaleFactor = beanieScalePlus; // Scale factor (2 means double the size)
|
||||
const beanieduration = 2500;
|
||||
this.tweens.add({
|
||||
targets: beanie,
|
||||
scaleX: beaniescaleFactor + 0.004,
|
||||
scaleY: beaniescaleFactor,
|
||||
duration: beanieduration,
|
||||
ease: 'Redial',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const backgroundImages = this.add.image(customWidth / 2, customHeight /2, 'backgroundImage').setDepth(-2).setScale(backgroundScale);
|
||||
this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'letterN').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'letterN').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'animatedN').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
maskGraphics.fillRect(customWidth / 2 - (canvas.width * canvasScale) / 2, customHeight / 2 + canvasHeight - (canvas.height * canvasScale) / 2, canvas.width * canvasScale, canvas.height * canvasScale);
|
||||
const mask = maskGraphics.createGeometryMask();
|
||||
|
||||
|
||||
|
||||
let hideButton = this.add.text(customWidth / 2 - 65, customHeight / 1.1, "Let`s Do", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(customWidth / 2 - 50, customHeight / 1.1, "Help!", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 20;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : N', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
const animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedNHeight, 'animatedN').setDepth(2).setScale(animatedNScale);
|
||||
|
||||
// Play the video
|
||||
animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
||||
// You can set additional properties for the video, such as loop and mute:
|
||||
animatedLetter.setLoop(true); // Loop the video
|
||||
animatedLetter.setMute(false); // Unmute the video
|
||||
animatedLetter.on('complete', function () {
|
||||
// add function after end video;
|
||||
});
|
||||
|
||||
let textX, textY;
|
||||
|
||||
firstLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Tall Down',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
firstLayer.setAlpha(0.5);
|
||||
firstLayer.setInteractive({ draggable: true });
|
||||
|
||||
secondLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer2').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
const secondTextLayer = this.add.text(textX, textY, '2. Tall Down',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioTwoAudio = this.sound.add('audioOne');
|
||||
secondTextLayer.setVisible(false);
|
||||
secondLayer.setDepth(1);
|
||||
secondLayer.setAlpha(0.5);
|
||||
secondLayer.setInteractive({ draggable: true });
|
||||
secondLayer.setVisible(false);
|
||||
|
||||
thirdLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer3').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 3 : customWidth * 0.75;
|
||||
const thirdTextLayer = this.add.text(textX, textY, '3. Slant', { font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioThreeAudio = this.sound.add('audioTwo');
|
||||
thirdTextLayer.setVisible(false);
|
||||
thirdLayer.setDepth(1.1);
|
||||
// thirdLayer.setScale(1.15);
|
||||
thirdLayer.setAlpha(0.5);
|
||||
thirdLayer.setInteractive({ draggable: true });
|
||||
thirdLayer.setVisible(false);
|
||||
|
||||
// Add these variables to keep track of start points
|
||||
let firstDragStartPoint = { x: 0, y: 0 };
|
||||
let secondDragStartPoint = { x: 0, y: 0 };
|
||||
let thirdDragStartPoint = { x: 0, y: 0 };
|
||||
|
||||
// ...
|
||||
|
||||
// Add this code for firstLayer
|
||||
firstLayer.on('dragstart', (pointer) => {
|
||||
firstDragStartPoint.x = pointer.x;
|
||||
firstDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
firstLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(firstDragStartPoint.x, firstDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
|
||||
firstTextLayer.setVisible(false);
|
||||
secondTextLayer.setVisible(true);
|
||||
audioTwoAudio.play();
|
||||
secondLayer.setVisible(true);
|
||||
firstLayer.setAlpha(1);
|
||||
secondLayer.setAlpha(0.5);
|
||||
thirdLayer.setAlpha(0.5);
|
||||
} else {
|
||||
firstLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
secondLayer.on('dragstart', (pointer) => {
|
||||
secondDragStartPoint.x = pointer.x;
|
||||
secondDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
secondLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(secondDragStartPoint.x, secondDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
secondTextLayer.setVisible(false);
|
||||
thirdTextLayer.setVisible(true);
|
||||
audioThreeAudio.play();
|
||||
thirdLayer.setVisible(true);
|
||||
secondLayer.setAlpha(1);
|
||||
thirdLayer.setAlpha(0.5);
|
||||
} else {
|
||||
secondLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
// Add this code for thirdLayer
|
||||
thirdLayer.on('dragstart', (pointer) => {
|
||||
thirdDragStartPoint.x = pointer.x;
|
||||
thirdDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
thirdLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(thirdDragStartPoint.x, thirdDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
thirdLayer.setAlpha(1);
|
||||
thirdTextLayer.setVisible(false);
|
||||
} else {
|
||||
thirdLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
graphics.moveTo(pointer.x, pointer.y);
|
||||
// console.log("Start Position", pointer.x, pointer.y)
|
||||
});
|
||||
|
||||
this.input.on('pointerup', function () {
|
||||
isDrawing = false;
|
||||
});
|
||||
|
||||
this.input.on('pointermove', function (pointer) {
|
||||
if (!isDrawing) return;
|
||||
|
||||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
}
|
||||
|
||||
function update() {
|
||||
}
|
||||
|
||||
</script>
|
||||
286
src/pages/capital-letter/O.astro
Normal file
286
src/pages/capital-letter/O.astro
Normal file
@@ -0,0 +1,286 @@
|
||||
---
|
||||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script is:inline>
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
width: isMobile ? window.innerWidth : window.innerWidth / 2,
|
||||
height: window.innerHeight / 2,
|
||||
};
|
||||
|
||||
const config = {
|
||||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
},
|
||||
scene: {
|
||||
preload: preload,
|
||||
create: create,
|
||||
update: update
|
||||
}
|
||||
};
|
||||
// backgroundImage.png
|
||||
const game = new Phaser.Game(config);
|
||||
const customWidth = window.innerWidth;
|
||||
const customHeight = window.innerHeight;
|
||||
let firstLayer, secondLayer, thirdLayer;
|
||||
let graphics;
|
||||
let isDrawing = false;
|
||||
|
||||
if(isMobile){
|
||||
cloudeSize = 200;
|
||||
cloudHeight = 340;
|
||||
canvasScale = 0.14
|
||||
canvasHeight = 35;
|
||||
letterHeight = 90;
|
||||
letterScale = 1;
|
||||
backgroundScale = 0.8;
|
||||
sunScale = 0.1;
|
||||
sunScalePlus = 0.15;
|
||||
sunWidth = 70;
|
||||
sunHeight = 70;
|
||||
beanieScale = 0.35;
|
||||
beanieScalePlus = 0.38;
|
||||
beanieWidth = 135;
|
||||
beanieHeight = 170;
|
||||
animatedOHeight = 32;
|
||||
} else{
|
||||
cloudeSize = 500;
|
||||
cloudHeight = 250;
|
||||
canvasScale = 0.195;
|
||||
canvasHeight = 20;
|
||||
letterHeight = 50;
|
||||
letterScale = 1;
|
||||
backgroundScale = 1;
|
||||
sunScale = 0.2;
|
||||
sunScalePlus = 0.25;
|
||||
sunWidth = 200;
|
||||
sunHeight = 100;
|
||||
beanieScale = 0.4;
|
||||
beanieScalePlus = 0.44;
|
||||
beanieWidth = 200;
|
||||
beanieHeight = 245;
|
||||
animatedOHeight = 20;
|
||||
}
|
||||
// let hideButton;
|
||||
|
||||
function preload() {
|
||||
this.load.video('animatedO', '/assets/animated-letter/capital_o.mp4');
|
||||
this.load.svg('letterO', '/assets/capital-letter/o.svg');
|
||||
this.load.svg('layer1', '/assets/capital-letter/o.svg');
|
||||
this.load.audio('audioOne', '/assets/audio/hook-arround-close.mp3');
|
||||
this.load.image('topLogo', '/assets/top_logo.png');
|
||||
this.load.svg('succesImage', '/assets/svg/tick.svg');
|
||||
this.load.svg('hintImage', '/assets/svg/hint.svg');
|
||||
this.load.svg('handPointer', '/assets/svg/hand.svg');
|
||||
this.load.image('backgroundImage', '/assets/bg6.png');
|
||||
this.load.image('cloud', '/assets/cloud.png');
|
||||
this.load.image('canvas', '/assets/canvas4.png');
|
||||
this.load.image('beanie', '/assets/beanieImage.png');
|
||||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
}
|
||||
|
||||
function create() {
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : O", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
// this.add.image(customWidth / 2, 50, 'cloud').setDepth(1.9);
|
||||
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
const sun = this.add.sprite(customWidth - sunWidth, sunHeight, 'sun').setScale(sunScale).setDepth(-1.9);
|
||||
const beanie = this.add.sprite(customWidth / 2 - beanieWidth, customHeight / 2 - beanieHeight, 'beanie').setScale(beanieScale).setDepth(1.9);
|
||||
|
||||
|
||||
const scaleFactor = sunScalePlus; // Scale factor (2 means double the size)
|
||||
const duration = 3000; // Duration of the animation in milliseconds
|
||||
|
||||
// Create a scaling tween
|
||||
this.tweens.add({
|
||||
targets: sun,
|
||||
scaleX: scaleFactor,
|
||||
scaleY: scaleFactor,
|
||||
duration: duration,
|
||||
ease: 'Linear',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const beaniescaleFactor = beanieScalePlus; // Scale factor (2 means double the size)
|
||||
const beanieduration = 2500;
|
||||
this.tweens.add({
|
||||
targets: beanie,
|
||||
scaleX: beaniescaleFactor + 0.004,
|
||||
scaleY: beaniescaleFactor,
|
||||
duration: beanieduration,
|
||||
ease: 'Redial',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const backgroundImages = this.add.image(customWidth / 2, customHeight /2, 'backgroundImage').setDepth(-2).setScale(backgroundScale);
|
||||
this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'letterO').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2 + 90, customHeight / 2 + letterHeight, 'letterO').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'animatedO').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
maskGraphics.fillRect(customWidth / 2 - (canvas.width * canvasScale) / 2, customHeight / 2 + canvasHeight - (canvas.height * canvasScale) / 2, canvas.width * canvasScale, canvas.height * canvasScale);
|
||||
const mask = maskGraphics.createGeometryMask();
|
||||
|
||||
|
||||
|
||||
let hideButton = this.add.text(customWidth / 2 - 65, customHeight / 1.1, "Let`s Do", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(customWidth / 2 - 50, customHeight / 1.1, "Help!", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 20;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : O', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
const animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedOHeight, 'animatedO').setDepth(2).setScale(0.73);
|
||||
|
||||
// Play the video
|
||||
animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
||||
// You can set additional properties for the video, such as loop and mute:
|
||||
animatedLetter.setLoop(true); // Loop the video
|
||||
animatedLetter.setMute(false); // Unmute the video
|
||||
animatedLetter.on('complete', function () {
|
||||
// Video playback is complete
|
||||
// You can add your code here for what to do when the video finishes.
|
||||
});
|
||||
|
||||
let textX, textY;
|
||||
|
||||
firstLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Hook Around Close',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
firstLayer.setAlpha(0.5);
|
||||
firstLayer.setInteractive({ draggable: true });
|
||||
|
||||
|
||||
|
||||
// Add these variables to keep track of start points
|
||||
let firstDragStartPoint = { x: 0, y: 0 };
|
||||
|
||||
// ...
|
||||
|
||||
// Add this code for firstLayer
|
||||
firstLayer.on('dragstart', (pointer) => {
|
||||
firstDragStartPoint.x = pointer.x;
|
||||
firstDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
firstLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(firstDragStartPoint.x, firstDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 50) {
|
||||
|
||||
firstTextLayer.setVisible(false);
|
||||
firstLayer.setAlpha(1);
|
||||
} else {
|
||||
firstLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
graphics.moveTo(pointer.x, pointer.y);
|
||||
});
|
||||
|
||||
this.input.on('pointerup', function () {
|
||||
isDrawing = false;
|
||||
});
|
||||
|
||||
this.input.on('pointermove', function (pointer) {
|
||||
if (!isDrawing) return;
|
||||
|
||||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
319
src/pages/capital-letter/P.astro
Normal file
319
src/pages/capital-letter/P.astro
Normal file
@@ -0,0 +1,319 @@
|
||||
---
|
||||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script is:inline>
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
width: isMobile ? window.innerWidth : window.innerWidth / 2,
|
||||
height: window.innerHeight / 2,
|
||||
};
|
||||
|
||||
const config = {
|
||||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
},
|
||||
scene: {
|
||||
preload: preload,
|
||||
create: create,
|
||||
update: update
|
||||
}
|
||||
};
|
||||
// backgroundImage.png
|
||||
const game = new Phaser.Game(config);
|
||||
const customWidth = window.innerWidth;
|
||||
const customHeight = window.innerHeight;
|
||||
let firstLayer, secondLayer;
|
||||
let graphics;
|
||||
let isDrawing = false;
|
||||
|
||||
if(isMobile){
|
||||
cloudeSize = 200;
|
||||
cloudHeight = 340;
|
||||
canvasScale = 0.14
|
||||
canvasHeight = 35;
|
||||
letterHeight = 58;
|
||||
letterScale = 0.85;
|
||||
backgroundScale = 0.8;
|
||||
sunScale = 0.1;
|
||||
sunScalePlus = 0.15;
|
||||
sunWidth = 70;
|
||||
sunHeight = 70;
|
||||
beanieScale = 0.35;
|
||||
beanieScalePlus = 0.38;
|
||||
beanieWidth = 135;
|
||||
beanieHeight = 170;
|
||||
animatedPHeight = 32;
|
||||
} else{
|
||||
cloudeSize = 500;
|
||||
cloudHeight = 250;
|
||||
canvasScale = 0.195;
|
||||
canvasHeight = 20;
|
||||
letterHeight = 50;
|
||||
letterScale = 1;
|
||||
backgroundScale = 1;
|
||||
sunScale = 0.2;
|
||||
sunScalePlus = 0.25;
|
||||
sunWidth = 200;
|
||||
sunHeight = 100;
|
||||
beanieScale = 0.4;
|
||||
beanieScalePlus = 0.44;
|
||||
beanieWidth = 200;
|
||||
beanieHeight = 245;
|
||||
animatedPHeight = 20;
|
||||
}
|
||||
// let hideButton;
|
||||
|
||||
function preload() {
|
||||
this.load.video('animatedP', '/assets/animated-letter/capital_p.mp4');
|
||||
this.load.svg('letterP', '/assets/capital-letter/p.svg');
|
||||
this.load.svg('layer1', '/assets/capital-letter/p_l1.svg');
|
||||
this.load.svg('layer2', '/assets/capital-letter/p_l2.svg');
|
||||
this.load.audio('audioOne', '/assets/audio/tall-down.mp3');
|
||||
this.load.audio('audioTwo', '/assets/audio/slide-around.mp3');
|
||||
this.load.image('topLogo', '/assets/top_logo.png');
|
||||
this.load.svg('succesImage', '/assets/svg/tick.svg');
|
||||
this.load.svg('hintImage', '/assets/svg/hint.svg');
|
||||
this.load.svg('handPointer', '/assets/svg/hand.svg');
|
||||
this.load.image('backgroundImage', '/assets/bg6.png');
|
||||
this.load.image('cloud', '/assets/cloud.png');
|
||||
this.load.image('canvas', '/assets/canvas4.png');
|
||||
this.load.image('beanie', '/assets/beanieImage.png');
|
||||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
}
|
||||
|
||||
function create() {
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : P", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
// this.add.image(customWidth / 2, 50, 'cloud').setDepth(1.9);
|
||||
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
const sun = this.add.sprite(customWidth - sunWidth, sunHeight, 'sun').setScale(sunScale).setDepth(-1.9);
|
||||
const beanie = this.add.sprite(customWidth / 2 - beanieWidth, customHeight / 2 - beanieHeight, 'beanie').setScale(beanieScale).setDepth(1.9);
|
||||
|
||||
|
||||
const scaleFactor = sunScalePlus; // Scale factor (2 means double the size)
|
||||
const duration = 3000; // Duration of the animation in milliseconds
|
||||
|
||||
// Create a scaling tween
|
||||
this.tweens.add({
|
||||
targets: sun,
|
||||
scaleX: scaleFactor,
|
||||
scaleY: scaleFactor,
|
||||
duration: duration,
|
||||
ease: 'Linear',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const beaniescaleFactor = beanieScalePlus; // Scale factor (2 means double the size)
|
||||
const beanieduration = 2500;
|
||||
this.tweens.add({
|
||||
targets: beanie,
|
||||
scaleX: beaniescaleFactor + 0.004,
|
||||
scaleY: beaniescaleFactor,
|
||||
duration: beanieduration,
|
||||
ease: 'Redial',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const backgroundImages = this.add.image(customWidth / 2, customHeight /2, 'backgroundImage').setDepth(-2).setScale(backgroundScale);
|
||||
this.add.image(customWidth / 2 + 30, customHeight / 2 + letterHeight, 'letterP').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'letterP').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'animatedP').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
maskGraphics.fillRect(customWidth / 2 - (canvas.width * canvasScale) / 2, customHeight / 2 + canvasHeight - (canvas.height * canvasScale) / 2, canvas.width * canvasScale, canvas.height * canvasScale);
|
||||
const mask = maskGraphics.createGeometryMask();
|
||||
|
||||
|
||||
|
||||
let hideButton = this.add.text(customWidth / 2 - 65, customHeight / 1.1, "Let`s Do", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(customWidth / 2 - 50, customHeight / 1.1, "Help!", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 20;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : P', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
const animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedPHeight, 'animatedP').setDepth(2).setScale(0.73);
|
||||
|
||||
// Play the video
|
||||
animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
||||
// You can set additional properties for the video, such as loop and mute:
|
||||
animatedLetter.setLoop(true); // Loop the video
|
||||
animatedLetter.setMute(false); // Unmute the video
|
||||
animatedLetter.on('complete', function () {
|
||||
// Video playback is complete
|
||||
// You can add your code here for what to do when the video finishes.
|
||||
});
|
||||
|
||||
let textX, textY;
|
||||
|
||||
firstLayer = this.add.image(customWidth / 2 + 30, customHeight / 2 + letterHeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Tall Down',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
firstLayer.setAlpha(0.5);
|
||||
firstLayer.setInteractive({ draggable: true });
|
||||
|
||||
secondLayer = this.add.image(customWidth / 2 + 30, customHeight / 2 + letterHeight, 'layer2').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
const secondTextLayer = this.add.text(textX, textY, '2. Slide Around',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioTwoAudio = this.sound.add('audioTwo');
|
||||
secondTextLayer.setVisible(false);
|
||||
secondLayer.setDepth(1);
|
||||
secondLayer.setAlpha(0.5);
|
||||
secondLayer.setInteractive({ draggable: true });
|
||||
secondLayer.setVisible(false);
|
||||
|
||||
|
||||
// Add these variables to keep track of start points
|
||||
let firstDragStartPoint = { x: 0, y: 0 };
|
||||
let secondDragStartPoint = { x: 0, y: 0 };
|
||||
|
||||
// ...
|
||||
|
||||
// Add this code for firstLayer
|
||||
firstLayer.on('dragstart', (pointer) => {
|
||||
firstDragStartPoint.x = pointer.x;
|
||||
firstDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
firstLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(firstDragStartPoint.x, firstDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
|
||||
firstTextLayer.setVisible(false);
|
||||
secondTextLayer.setVisible(true);
|
||||
audioTwoAudio.play();
|
||||
secondLayer.setVisible(true);
|
||||
firstLayer.setAlpha(1);
|
||||
secondLayer.setAlpha(0.5);
|
||||
} else {
|
||||
firstLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
``
|
||||
// Repeat the above code for secondLayer and thirdLayer
|
||||
|
||||
// Add this code for secondLayer
|
||||
secondLayer.on('dragstart', (pointer) => {
|
||||
secondDragStartPoint.x = pointer.x;
|
||||
secondDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
secondLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(secondDragStartPoint.x, secondDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >=100) {
|
||||
secondTextLayer.setVisible(false);
|
||||
secondLayer.setAlpha(1);
|
||||
} else {
|
||||
secondLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
graphics.moveTo(pointer.x, pointer.y);
|
||||
console.log("Start Position", pointer.x, pointer.y)
|
||||
});
|
||||
|
||||
this.input.on('pointerup', function () {
|
||||
isDrawing = false;
|
||||
});
|
||||
|
||||
this.input.on('pointermove', function (pointer) {
|
||||
if (!isDrawing) return;
|
||||
|
||||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
319
src/pages/capital-letter/Q.astro
Normal file
319
src/pages/capital-letter/Q.astro
Normal file
@@ -0,0 +1,319 @@
|
||||
---
|
||||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script is:inline>
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
width: isMobile ? window.innerWidth : window.innerWidth / 2,
|
||||
height: window.innerHeight / 2,
|
||||
};
|
||||
|
||||
const config = {
|
||||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
},
|
||||
scene: {
|
||||
preload: preload,
|
||||
create: create,
|
||||
update: update
|
||||
}
|
||||
};
|
||||
// backgroundImage.png
|
||||
const game = new Phaser.Game(config);
|
||||
const customWidth = window.innerWidth;
|
||||
const customHeight = window.innerHeight;
|
||||
let firstLayer, secondLayer;
|
||||
let graphics;
|
||||
let isDrawing = false;
|
||||
|
||||
if(isMobile){
|
||||
cloudeSize = 200;
|
||||
cloudHeight = 340;
|
||||
canvasScale = 0.14
|
||||
canvasHeight = 35;
|
||||
letterHeight = 58;
|
||||
letterScale = 0.85;
|
||||
backgroundScale = 0.8;
|
||||
sunScale = 0.1;
|
||||
sunScalePlus = 0.15;
|
||||
sunWidth = 70;
|
||||
sunHeight = 70;
|
||||
beanieScale = 0.35;
|
||||
beanieScalePlus = 0.38;
|
||||
beanieWidth = 135;
|
||||
beanieHeight = 170;
|
||||
animatedQHeight = 32;
|
||||
} else{
|
||||
cloudeSize = 500;
|
||||
cloudHeight = 250;
|
||||
canvasScale = 0.195;
|
||||
canvasHeight = 20;
|
||||
letterHeight = 50;
|
||||
letterScale = 1;
|
||||
backgroundScale = 1;
|
||||
sunScale = 0.2;
|
||||
sunScalePlus = 0.25;
|
||||
sunWidth = 200;
|
||||
sunHeight = 100;
|
||||
beanieScale = 0.4;
|
||||
beanieScalePlus = 0.44;
|
||||
beanieWidth = 200;
|
||||
beanieHeight = 245;
|
||||
animatedQHeight = 20;
|
||||
}
|
||||
// let hideButton;
|
||||
|
||||
function preload() {
|
||||
this.load.video('animatedQ', '/assets/animated-letter/capital_q.mp4');
|
||||
this.load.svg('letterQ', '/assets/capital-letter/q.svg');
|
||||
this.load.svg('layer1', '/assets/capital-letter/q_l1.svg');
|
||||
this.load.svg('layer2', '/assets/capital-letter/q_l2.svg');
|
||||
this.load.audio('audioOne', '/assets/audio/tall-down.mp3');
|
||||
this.load.audio('audioTwo', '/assets/audio/slide-around.mp3');
|
||||
this.load.image('topLogo', '/assets/top_logo.png');
|
||||
this.load.svg('succesImage', '/assets/svg/tick.svg');
|
||||
this.load.svg('hintImage', '/assets/svg/hint.svg');
|
||||
this.load.svg('handPointer', '/assets/svg/hand.svg');
|
||||
this.load.image('backgroundImage', '/assets/bg6.png');
|
||||
this.load.image('cloud', '/assets/cloud.png');
|
||||
this.load.image('canvas', '/assets/canvas4.png');
|
||||
this.load.image('beanie', '/assets/beanieImage.png');
|
||||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
}
|
||||
|
||||
function create() {
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : Q", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
// this.add.image(customWidth / 2, 50, 'cloud').setDepth(1.9);
|
||||
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
const sun = this.add.sprite(customWidth - sunWidth, sunHeight, 'sun').setScale(sunScale).setDepth(-1.9);
|
||||
const beanie = this.add.sprite(customWidth / 2 - beanieWidth, customHeight / 2 - beanieHeight, 'beanie').setScale(beanieScale).setDepth(1.9);
|
||||
|
||||
|
||||
const scaleFactor = sunScalePlus; // Scale factor (2 means double the size)
|
||||
const duration = 3000; // Duration of the animation in milliseconds
|
||||
|
||||
// Create a scaling tween
|
||||
this.tweens.add({
|
||||
targets: sun,
|
||||
scaleX: scaleFactor,
|
||||
scaleY: scaleFactor,
|
||||
duration: duration,
|
||||
ease: 'Linear',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const beaniescaleFactor = beanieScalePlus; // Scale factor (2 means double the size)
|
||||
const beanieduration = 2500;
|
||||
this.tweens.add({
|
||||
targets: beanie,
|
||||
scaleX: beaniescaleFactor + 0.004,
|
||||
scaleY: beaniescaleFactor,
|
||||
duration: beanieduration,
|
||||
ease: 'Redial',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const backgroundImages = this.add.image(customWidth / 2, customHeight /2, 'backgroundImage').setDepth(-2).setScale(backgroundScale);
|
||||
this.add.image(customWidth / 2 + 30, customHeight / 2 + letterHeight, 'letterQ').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'letterQ').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'animatedQ').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
maskGraphics.fillRect(customWidth / 2 - (canvas.width * canvasScale) / 2, customHeight / 2 + canvasHeight - (canvas.height * canvasScale) / 2, canvas.width * canvasScale, canvas.height * canvasScale);
|
||||
const mask = maskGraphics.createGeometryMask();
|
||||
|
||||
|
||||
|
||||
let hideButton = this.add.text(customWidth / 2 - 65, customHeight / 1.1, "Let`s Do", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(customWidth / 2 - 50, customHeight / 1.1, "Help!", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 20;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : Q', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
const animatedLetter = this.add.video(customWidth / 2 + 40 , customHeight / 2 + animatedQHeight, 'animatedQ').setDepth(2).setScale(0.73);
|
||||
|
||||
// Play the video
|
||||
animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
||||
// You can set additional properties for the video, such as loop and mute:
|
||||
animatedLetter.setLoop(true); // Loop the video
|
||||
animatedLetter.setMute(false); // Unmute the video
|
||||
animatedLetter.on('complete', function () {
|
||||
// Video playback is complete
|
||||
// You can add your code here for what to do when the video finishes.
|
||||
});
|
||||
|
||||
let textX, textY;
|
||||
|
||||
firstLayer = this.add.image(customWidth / 2 + 30, customHeight / 2 + letterHeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Hook Around Close',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
firstLayer.setAlpha(0.5);
|
||||
firstLayer.setInteractive({ draggable: true });
|
||||
|
||||
secondLayer = this.add.image(customWidth / 2 + 30, customHeight / 2 + letterHeight, 'layer2').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
const secondTextLayer = this.add.text(textX, textY, '2. Slant',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioTwoAudio = this.sound.add('audioTwo');
|
||||
secondTextLayer.setVisible(false);
|
||||
secondLayer.setDepth(1);
|
||||
secondLayer.setAlpha(0.5);
|
||||
secondLayer.setInteractive({ draggable: true });
|
||||
secondLayer.setVisible(false);
|
||||
|
||||
|
||||
// Add these variables to keep track of start points
|
||||
let firstDragStartPoint = { x: 0, y: 0 };
|
||||
let secondDragStartPoint = { x: 0, y: 0 };
|
||||
|
||||
// ...
|
||||
|
||||
// Add this code for firstLayer
|
||||
firstLayer.on('dragstart', (pointer) => {
|
||||
firstDragStartPoint.x = pointer.x;
|
||||
firstDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
firstLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(firstDragStartPoint.x, firstDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
|
||||
firstTextLayer.setVisible(false);
|
||||
secondTextLayer.setVisible(true);
|
||||
audioTwoAudio.play();
|
||||
secondLayer.setVisible(true);
|
||||
firstLayer.setAlpha(1);
|
||||
secondLayer.setAlpha(0.5);
|
||||
} else {
|
||||
firstLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
``
|
||||
// Repeat the above code for secondLayer and thirdLayer
|
||||
|
||||
// Add this code for secondLayer
|
||||
secondLayer.on('dragstart', (pointer) => {
|
||||
secondDragStartPoint.x = pointer.x;
|
||||
secondDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
secondLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(secondDragStartPoint.x, secondDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >=100) {
|
||||
secondTextLayer.setVisible(false);
|
||||
secondLayer.setAlpha(1);
|
||||
} else {
|
||||
secondLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
graphics.moveTo(pointer.x, pointer.y);
|
||||
console.log("Start Position", pointer.x, pointer.y)
|
||||
});
|
||||
|
||||
this.input.on('pointerup', function () {
|
||||
isDrawing = false;
|
||||
});
|
||||
|
||||
this.input.on('pointermove', function (pointer) {
|
||||
if (!isDrawing) return;
|
||||
|
||||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
351
src/pages/capital-letter/R.astro
Normal file
351
src/pages/capital-letter/R.astro
Normal file
@@ -0,0 +1,351 @@
|
||||
---
|
||||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script is:inline>
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
width: isMobile ? window.innerWidth : window.innerWidth / 2,
|
||||
height: window.innerHeight / 2,
|
||||
};
|
||||
|
||||
const config = {
|
||||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
},
|
||||
scene: {
|
||||
preload: preload,
|
||||
create: create,
|
||||
update: update
|
||||
}
|
||||
};
|
||||
// backgroundImage.png
|
||||
const game = new Phaser.Game(config);
|
||||
const customWidth = window.innerWidth;
|
||||
const customHeight = window.innerHeight;
|
||||
let firstLayer, secondLayer, thirdLayer;
|
||||
let graphics;
|
||||
let isDrawing = false;
|
||||
// let x = 100;
|
||||
|
||||
// // Use x
|
||||
// console.log(x);
|
||||
|
||||
if(isMobile){
|
||||
cloudeSize = 200;
|
||||
cloudHeight = 340;
|
||||
canvasScale = 0.14
|
||||
canvasHeight = 35;
|
||||
letterHeight = 70;
|
||||
letterScale = 1;
|
||||
backgroundScale = 0.8;
|
||||
sunScale = 0.1;
|
||||
sunScalePlus = 0.15;
|
||||
sunWidth = 70;
|
||||
sunHeight = 70;
|
||||
beanieScale = 0.35;
|
||||
beanieScalePlus = 0.365;
|
||||
beanieWidth = 135;
|
||||
beanieHeight = 170;
|
||||
animatedRHeight = 35;
|
||||
animatedRScale = 0.65;
|
||||
} else{
|
||||
cloudeSize = 500;
|
||||
cloudHeight = 250;
|
||||
canvasScale = 0.195;
|
||||
canvasHeight = 20;
|
||||
letterHeight = 50;
|
||||
letterScale = 1;
|
||||
backgroundScale = 1;
|
||||
sunScale = 0.2;
|
||||
sunScalePlus = 0.25;
|
||||
sunWidth = 200;
|
||||
sunHeight = 100;
|
||||
beanieScale = 0.4;
|
||||
beanieScalePlus = 0.45;
|
||||
beanieWidth = 200;
|
||||
beanieHeight = 255;
|
||||
animatedRHeight = 20;
|
||||
animatedRScale = 0.73;
|
||||
}
|
||||
function preload() {
|
||||
this.load.video('animatedR', '/assets/animated-letter/capital_r.mp4');
|
||||
this.load.svg('letterR', '/assets/capital-letter/r.svg');
|
||||
this.load.svg('layer1', '/assets/capital-letter/r_l1.svg');
|
||||
this.load.svg('layer2', '/assets/capital-letter/r_l2.svg');
|
||||
this.load.svg('layer3', '/assets/capital-letter/r_l3.svg');
|
||||
this.load.audio('audioOne', '/assets/audio/tall-down.mp3');
|
||||
this.load.audio('audioTwo', '/assets/audio/slide-around.mp3');
|
||||
this.load.audio('audioThree', '/assets/audio/slant.mp3');
|
||||
this.load.image('topLogo', '/assets/top_logo.png');
|
||||
this.load.svg('succesImage', '/assets/svg/tick.svg');
|
||||
this.load.svg('hintImage', '/assets/svg/hint.svg');
|
||||
this.load.svg('handPointer', '/assets/svg/hand.svg');
|
||||
this.load.image('backgroundImage', '/assets/bg6.png');
|
||||
this.load.image('cloud', '/assets/cloud.png');
|
||||
this.load.image('canvas', '/assets/canvas4.png');
|
||||
// this.load.image('beanie', '/assets/beanie.png');
|
||||
this.load.image('beanie', '/assets/beanieImage.png');
|
||||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
}
|
||||
|
||||
function create() {
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : R", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
const sun = this.add.sprite(customWidth - sunWidth, sunHeight, 'sun').setScale(sunScale).setDepth(-1.9);
|
||||
const beanie = this.add.sprite(customWidth / 2 - beanieWidth, customHeight / 2 - beanieHeight, 'beanie').setScale(beanieScale).setDepth(1.9);
|
||||
|
||||
|
||||
const scaleFactor = sunScalePlus; // Scale factor (2 means double the size)
|
||||
const duration = 3000; // Duration of the animation in milliseconds
|
||||
|
||||
// Create a scaling tween
|
||||
this.tweens.add({
|
||||
targets: sun,
|
||||
scaleX: scaleFactor,
|
||||
scaleY: scaleFactor,
|
||||
duration: duration,
|
||||
ease: 'Linear',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const beaniescaleFactor = beanieScalePlus; // Scale factor (2 means double the size)
|
||||
const beanieduration = 2500;
|
||||
this.tweens.add({
|
||||
targets: beanie,
|
||||
scaleX: beaniescaleFactor + 0.004,
|
||||
scaleY: beaniescaleFactor,
|
||||
duration: beanieduration,
|
||||
ease: 'Redial',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const backgroundImages = this.add.image(customWidth / 2, customHeight /2, 'backgroundImage').setDepth(-2).setScale(backgroundScale);
|
||||
this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'letterR').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'letterR').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'animatedR').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
maskGraphics.fillRect(customWidth / 2 - (canvas.width * canvasScale) / 2, customHeight / 2 + canvasHeight - (canvas.height * canvasScale) / 2, canvas.width * canvasScale, canvas.height * canvasScale);
|
||||
const mask = maskGraphics.createGeometryMask();
|
||||
|
||||
|
||||
|
||||
let hideButton = this.add.text(customWidth / 2 - 65, customHeight / 1.1, "Let`s Do", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(customWidth / 2 - 50, customHeight / 1.1, "Help!", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 20;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : R', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
const animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedRHeight, 'animatedR').setDepth(2).setScale(animatedRScale);
|
||||
|
||||
// Play the video
|
||||
animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
||||
// You can set additional properties for the video, such as loop and mute:
|
||||
animatedLetter.setLoop(true); // Loop the video
|
||||
animatedLetter.setMute(false); // Unmute the video
|
||||
animatedLetter.on('complete', function () {
|
||||
// add function after end video;
|
||||
});
|
||||
|
||||
let textX, textY;
|
||||
|
||||
firstLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Tall Down',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
firstLayer.setAlpha(0.5);
|
||||
firstLayer.setInteractive({ draggable: true });
|
||||
|
||||
secondLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer2').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
const secondTextLayer = this.add.text(textX, textY, '2. Slide Around',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioTwoAudio = this.sound.add('audioTwo');
|
||||
secondTextLayer.setVisible(false);
|
||||
secondLayer.setDepth(1);
|
||||
secondLayer.setAlpha(0.5);
|
||||
secondLayer.setInteractive({ draggable: true });
|
||||
secondLayer.setVisible(false);
|
||||
|
||||
thirdLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer3').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 3 : customWidth * 0.75;
|
||||
const thirdTextLayer = this.add.text(textX, textY, '3. Slant', { font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioThreeAudio = this.sound.add('audioThree');
|
||||
thirdTextLayer.setVisible(false);
|
||||
thirdLayer.setDepth(1.1);
|
||||
// thirdLayer.setScale(1.15);
|
||||
thirdLayer.setAlpha(0.5);
|
||||
thirdLayer.setInteractive({ draggable: true });
|
||||
thirdLayer.setVisible(false);
|
||||
|
||||
// Add these variables to keep track of start points
|
||||
let firstDragStartPoint = { x: 0, y: 0 };
|
||||
let secondDragStartPoint = { x: 0, y: 0 };
|
||||
let thirdDragStartPoint = { x: 0, y: 0 };
|
||||
|
||||
// ...
|
||||
|
||||
// Add this code for firstLayer
|
||||
firstLayer.on('dragstart', (pointer) => {
|
||||
firstDragStartPoint.x = pointer.x;
|
||||
firstDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
firstLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(firstDragStartPoint.x, firstDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
|
||||
firstTextLayer.setVisible(false);
|
||||
secondTextLayer.setVisible(true);
|
||||
audioTwoAudio.play();
|
||||
secondLayer.setVisible(true);
|
||||
firstLayer.setAlpha(1);
|
||||
secondLayer.setAlpha(0.5);
|
||||
thirdLayer.setAlpha(0.5);
|
||||
} else {
|
||||
firstLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
secondLayer.on('dragstart', (pointer) => {
|
||||
secondDragStartPoint.x = pointer.x;
|
||||
secondDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
secondLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(secondDragStartPoint.x, secondDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
secondTextLayer.setVisible(false);
|
||||
thirdTextLayer.setVisible(true);
|
||||
audioThreeAudio.play();
|
||||
thirdLayer.setVisible(true);
|
||||
secondLayer.setAlpha(1);
|
||||
thirdLayer.setAlpha(0.5);
|
||||
} else {
|
||||
secondLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
// Add this code for thirdLayer
|
||||
thirdLayer.on('dragstart', (pointer) => {
|
||||
thirdDragStartPoint.x = pointer.x;
|
||||
thirdDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
thirdLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(thirdDragStartPoint.x, thirdDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
thirdLayer.setAlpha(1);
|
||||
thirdTextLayer.setVisible(false);
|
||||
} else {
|
||||
thirdLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
graphics.moveTo(pointer.x, pointer.y);
|
||||
// console.log("Start Position", pointer.x, pointer.y)
|
||||
});
|
||||
|
||||
this.input.on('pointerup', function () {
|
||||
isDrawing = false;
|
||||
});
|
||||
|
||||
this.input.on('pointermove', function (pointer) {
|
||||
if (!isDrawing) return;
|
||||
|
||||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
}
|
||||
|
||||
function update() {
|
||||
}
|
||||
|
||||
</script>
|
||||
286
src/pages/capital-letter/S.astro
Normal file
286
src/pages/capital-letter/S.astro
Normal file
@@ -0,0 +1,286 @@
|
||||
---
|
||||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script is:inline>
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
width: isMobile ? window.innerWidth : window.innerWidth / 2,
|
||||
height: window.innerHeight / 2,
|
||||
};
|
||||
|
||||
const config = {
|
||||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
},
|
||||
scene: {
|
||||
preload: preload,
|
||||
create: create,
|
||||
update: update
|
||||
}
|
||||
};
|
||||
// backgroundImage.png
|
||||
const game = new Phaser.Game(config);
|
||||
const customWidth = window.innerWidth;
|
||||
const customHeight = window.innerHeight;
|
||||
let firstLayer, secondLayer, thirdLayer;
|
||||
let graphics;
|
||||
let isDrawing = false;
|
||||
|
||||
if(isMobile){
|
||||
cloudeSize = 200;
|
||||
cloudHeight = 340;
|
||||
canvasScale = 0.14
|
||||
canvasHeight = 35;
|
||||
letterHeight = 90;
|
||||
letterScale = 1;
|
||||
backgroundScale = 0.8;
|
||||
sunScale = 0.1;
|
||||
sunScalePlus = 0.15;
|
||||
sunWidth = 70;
|
||||
sunHeight = 70;
|
||||
beanieScale = 0.35;
|
||||
beanieScalePlus = 0.38;
|
||||
beanieWidth = 135;
|
||||
beanieHeight = 170;
|
||||
animatedSHeight = 32;
|
||||
} else{
|
||||
cloudeSize = 500;
|
||||
cloudHeight = 250;
|
||||
canvasScale = 0.195;
|
||||
canvasHeight = 20;
|
||||
letterHeight = 50;
|
||||
letterScale = 1;
|
||||
backgroundScale = 1;
|
||||
sunScale = 0.2;
|
||||
sunScalePlus = 0.25;
|
||||
sunWidth = 200;
|
||||
sunHeight = 100;
|
||||
beanieScale = 0.4;
|
||||
beanieScalePlus = 0.44;
|
||||
beanieWidth = 200;
|
||||
beanieHeight = 245;
|
||||
animatedSHeight = 20;
|
||||
}
|
||||
// let hideButton;
|
||||
|
||||
function preload() {
|
||||
this.load.video('animatedS', '/assets/animated-letter/capital_s.mp4');
|
||||
this.load.svg('letterS', '/assets/capital-letter/s.svg');
|
||||
this.load.svg('layer1', '/assets/capital-letter/s.svg');
|
||||
this.load.audio('audioOne', '/assets/audio/hook-around-snake.mp3');
|
||||
this.load.image('topLogo', '/assets/top_logo.png');
|
||||
this.load.svg('succesImage', '/assets/svg/tick.svg');
|
||||
this.load.svg('hintImage', '/assets/svg/hint.svg');
|
||||
this.load.svg('handPointer', '/assets/svg/hand.svg');
|
||||
this.load.image('backgroundImage', '/assets/bg6.png');
|
||||
this.load.image('cloud', '/assets/cloud.png');
|
||||
this.load.image('canvas', '/assets/canvas4.png');
|
||||
this.load.image('beanie', '/assets/beanieImage.png');
|
||||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
}
|
||||
|
||||
function create() {
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : S", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
// this.add.image(customWidth / 2, 50, 'cloud').setDepth(1.9);
|
||||
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
const sun = this.add.sprite(customWidth - sunWidth, sunHeight, 'sun').setScale(sunScale).setDepth(-1.9);
|
||||
const beanie = this.add.sprite(customWidth / 2 - beanieWidth, customHeight / 2 - beanieHeight, 'beanie').setScale(beanieScale).setDepth(1.9);
|
||||
|
||||
|
||||
const scaleFactor = sunScalePlus; // Scale factor (2 means double the size)
|
||||
const duration = 3000; // Duration of the animation in milliseconds
|
||||
|
||||
// Create a scaling tween
|
||||
this.tweens.add({
|
||||
targets: sun,
|
||||
scaleX: scaleFactor,
|
||||
scaleY: scaleFactor,
|
||||
duration: duration,
|
||||
ease: 'Linear',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const beaniescaleFactor = beanieScalePlus; // Scale factor (2 means double the size)
|
||||
const beanieduration = 2500;
|
||||
this.tweens.add({
|
||||
targets: beanie,
|
||||
scaleX: beaniescaleFactor + 0.004,
|
||||
scaleY: beaniescaleFactor,
|
||||
duration: beanieduration,
|
||||
ease: 'Redial',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const backgroundImages = this.add.image(customWidth / 2, customHeight /2, 'backgroundImage').setDepth(-2).setScale(backgroundScale);
|
||||
this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'letterS').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2 + 90, customHeight / 2 + letterHeight, 'letterS').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'animatedS').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
maskGraphics.fillRect(customWidth / 2 - (canvas.width * canvasScale) / 2, customHeight / 2 + canvasHeight - (canvas.height * canvasScale) / 2, canvas.width * canvasScale, canvas.height * canvasScale);
|
||||
const mask = maskGraphics.createGeometryMask();
|
||||
|
||||
|
||||
|
||||
let hideButton = this.add.text(customWidth / 2 - 65, customHeight / 1.1, "Let`s Do", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(customWidth / 2 - 50, customHeight / 1.1, "Help!", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 20;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : S', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
const animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedSHeight, 'animatedS').setDepth(2).setScale(0.73);
|
||||
|
||||
// Play the video
|
||||
animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
||||
// You can set additional properties for the video, such as loop and mute:
|
||||
animatedLetter.setLoop(true); // Loop the video
|
||||
animatedLetter.setMute(false); // Unmute the video
|
||||
animatedLetter.on('complete', function () {
|
||||
// Video playback is complete
|
||||
// You can add your code here for what to do when the video finishes.
|
||||
});
|
||||
|
||||
let textX, textY;
|
||||
|
||||
firstLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Hook Around Snake',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
firstLayer.setAlpha(0.5);
|
||||
firstLayer.setInteractive({ draggable: true });
|
||||
|
||||
|
||||
|
||||
// Add these variables to keep track of start points
|
||||
let firstDragStartPoint = { x: 0, y: 0 };
|
||||
|
||||
// ...
|
||||
|
||||
// Add this code for firstLayer
|
||||
firstLayer.on('dragstart', (pointer) => {
|
||||
firstDragStartPoint.x = pointer.x;
|
||||
firstDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
firstLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(firstDragStartPoint.x, firstDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 50) {
|
||||
|
||||
firstTextLayer.setVisible(false);
|
||||
firstLayer.setAlpha(1);
|
||||
} else {
|
||||
firstLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
graphics.moveTo(pointer.x, pointer.y);
|
||||
});
|
||||
|
||||
this.input.on('pointerup', function () {
|
||||
isDrawing = false;
|
||||
});
|
||||
|
||||
this.input.on('pointermove', function (pointer) {
|
||||
if (!isDrawing) return;
|
||||
|
||||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
319
src/pages/capital-letter/T.astro
Normal file
319
src/pages/capital-letter/T.astro
Normal file
@@ -0,0 +1,319 @@
|
||||
---
|
||||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script is:inline>
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
width: isMobile ? window.innerWidth : window.innerWidth / 2,
|
||||
height: window.innerHeight / 2,
|
||||
};
|
||||
|
||||
const config = {
|
||||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
},
|
||||
scene: {
|
||||
preload: preload,
|
||||
create: create,
|
||||
update: update
|
||||
}
|
||||
};
|
||||
// backgroundImage.png
|
||||
const game = new Phaser.Game(config);
|
||||
const customWidth = window.innerWidth;
|
||||
const customHeight = window.innerHeight;
|
||||
let firstLayer, secondLayer;
|
||||
let graphics;
|
||||
let isDrawing = false;
|
||||
|
||||
if(isMobile){
|
||||
cloudeSize = 200;
|
||||
cloudHeight = 340;
|
||||
canvasScale = 0.14
|
||||
canvasHeight = 35;
|
||||
letterHeight = 58;
|
||||
letterScale = 0.85;
|
||||
backgroundScale = 0.8;
|
||||
sunScale = 0.1;
|
||||
sunScalePlus = 0.15;
|
||||
sunWidth = 70;
|
||||
sunHeight = 70;
|
||||
beanieScale = 0.35;
|
||||
beanieScalePlus = 0.38;
|
||||
beanieWidth = 135;
|
||||
beanieHeight = 170;
|
||||
animatedTHeight = 32;
|
||||
} else{
|
||||
cloudeSize = 500;
|
||||
cloudHeight = 250;
|
||||
canvasScale = 0.195;
|
||||
canvasHeight = 20;
|
||||
letterHeight = 50;
|
||||
letterScale = 1;
|
||||
backgroundScale = 1;
|
||||
sunScale = 0.2;
|
||||
sunScalePlus = 0.25;
|
||||
sunWidth = 200;
|
||||
sunHeight = 100;
|
||||
beanieScale = 0.4;
|
||||
beanieScalePlus = 0.44;
|
||||
beanieWidth = 200;
|
||||
beanieHeight = 245;
|
||||
animatedTHeight = 20;
|
||||
}
|
||||
// let hideButton;
|
||||
|
||||
function preload() {
|
||||
this.load.video('animatedT', '/assets/animated-letter/capital_t.mp4');
|
||||
this.load.svg('letterT', '/assets/capital-letter/t.svg');
|
||||
this.load.svg('layer1', '/assets/capital-letter/t_l1.svg');
|
||||
this.load.svg('layer2', '/assets/capital-letter/t_l2.svg');
|
||||
this.load.audio('audioOne', '/assets/audio/tall-down.mp3');
|
||||
this.load.audio('audioTwo', '/assets/audio/slide.mp3');
|
||||
this.load.image('topLogo', '/assets/top_logo.png');
|
||||
this.load.svg('succesImage', '/assets/svg/tick.svg');
|
||||
this.load.svg('hintImage', '/assets/svg/hint.svg');
|
||||
this.load.svg('handPointer', '/assets/svg/hand.svg');
|
||||
this.load.image('backgroundImage', '/assets/bg6.png');
|
||||
this.load.image('cloud', '/assets/cloud.png');
|
||||
this.load.image('canvas', '/assets/canvas4.png');
|
||||
this.load.image('beanie', '/assets/beanieImage.png');
|
||||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
}
|
||||
|
||||
function create() {
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : T", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
// this.add.image(customWidth / 2, 50, 'cloud').setDepth(1.9);
|
||||
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
const sun = this.add.sprite(customWidth - sunWidth, sunHeight, 'sun').setScale(sunScale).setDepth(-1.9);
|
||||
const beanie = this.add.sprite(customWidth / 2 - beanieWidth, customHeight / 2 - beanieHeight, 'beanie').setScale(beanieScale).setDepth(1.9);
|
||||
|
||||
|
||||
const scaleFactor = sunScalePlus; // Scale factor (2 means double the size)
|
||||
const duration = 3000; // Duration of the animation in milliseconds
|
||||
|
||||
// Create a scaling tween
|
||||
this.tweens.add({
|
||||
targets: sun,
|
||||
scaleX: scaleFactor,
|
||||
scaleY: scaleFactor,
|
||||
duration: duration,
|
||||
ease: 'Linear',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const beaniescaleFactor = beanieScalePlus; // Scale factor (2 means double the size)
|
||||
const beanieduration = 2500;
|
||||
this.tweens.add({
|
||||
targets: beanie,
|
||||
scaleX: beaniescaleFactor + 0.004,
|
||||
scaleY: beaniescaleFactor,
|
||||
duration: beanieduration,
|
||||
ease: 'Redial',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const backgroundImages = this.add.image(customWidth / 2, customHeight /2, 'backgroundImage').setDepth(-2).setScale(backgroundScale);
|
||||
this.add.image(customWidth / 2 - 30, customHeight / 2 + letterHeight, 'letterT').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2 - 30, customHeight / 2 + letterHeight, 'letterT').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'animatedT').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
maskGraphics.fillRect(customWidth / 2 - (canvas.width * canvasScale) / 2, customHeight / 2 + canvasHeight - (canvas.height * canvasScale) / 2, canvas.width * canvasScale, canvas.height * canvasScale);
|
||||
const mask = maskGraphics.createGeometryMask();
|
||||
|
||||
|
||||
|
||||
let hideButton = this.add.text(customWidth / 2 - 65, customHeight / 1.1, "Let`s Do", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(customWidth / 2 - 50, customHeight / 1.1, "Help!", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 20;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : T', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
const animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedTHeight, 'animatedT').setDepth(2).setScale(0.73);
|
||||
|
||||
// Play the video
|
||||
animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
||||
// You can set additional properties for the video, such as loop and mute:
|
||||
animatedLetter.setLoop(true); // Loop the video
|
||||
animatedLetter.setMute(false); // Unmute the video
|
||||
animatedLetter.on('complete', function () {
|
||||
// Video playback is complete
|
||||
// You can add your code here for what to do when the video finishes.
|
||||
});
|
||||
|
||||
let textX, textY;
|
||||
|
||||
firstLayer = this.add.image(customWidth / 2 - 30, customHeight / 2 + letterHeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Tall Down',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
firstLayer.setAlpha(0.5);
|
||||
firstLayer.setInteractive({ draggable: true });
|
||||
|
||||
secondLayer = this.add.image(customWidth / 2 - 30, customHeight / 2 + letterHeight, 'layer2').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
const secondTextLayer = this.add.text(textX, textY, '2. Slide',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioTwoAudio = this.sound.add('audioTwo');
|
||||
secondTextLayer.setVisible(false);
|
||||
secondLayer.setDepth(1);
|
||||
secondLayer.setAlpha(0.5);
|
||||
secondLayer.setInteractive({ draggable: true });
|
||||
secondLayer.setVisible(false);
|
||||
|
||||
|
||||
// Add these variables to keep track of start points
|
||||
let firstDragStartPoint = { x: 0, y: 0 };
|
||||
let secondDragStartPoint = { x: 0, y: 0 };
|
||||
|
||||
// ...
|
||||
|
||||
// Add this code for firstLayer
|
||||
firstLayer.on('dragstart', (pointer) => {
|
||||
firstDragStartPoint.x = pointer.x;
|
||||
firstDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
firstLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(firstDragStartPoint.x, firstDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
|
||||
firstTextLayer.setVisible(false);
|
||||
secondTextLayer.setVisible(true);
|
||||
audioTwoAudio.play();
|
||||
secondLayer.setVisible(true);
|
||||
firstLayer.setAlpha(1);
|
||||
secondLayer.setAlpha(0.5);
|
||||
} else {
|
||||
firstLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
``
|
||||
// Repeat the above code for secondLayer and thirdLayer
|
||||
|
||||
// Add this code for secondLayer
|
||||
secondLayer.on('dragstart', (pointer) => {
|
||||
secondDragStartPoint.x = pointer.x;
|
||||
secondDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
secondLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(secondDragStartPoint.x, secondDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >=100) {
|
||||
secondTextLayer.setVisible(false);
|
||||
secondLayer.setAlpha(1);
|
||||
} else {
|
||||
secondLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
graphics.moveTo(pointer.x, pointer.y);
|
||||
console.log("Start Position", pointer.x, pointer.y)
|
||||
});
|
||||
|
||||
this.input.on('pointerup', function () {
|
||||
isDrawing = false;
|
||||
});
|
||||
|
||||
this.input.on('pointermove', function (pointer) {
|
||||
if (!isDrawing) return;
|
||||
|
||||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
286
src/pages/capital-letter/U.astro
Normal file
286
src/pages/capital-letter/U.astro
Normal file
@@ -0,0 +1,286 @@
|
||||
---
|
||||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script is:inline>
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
width: isMobile ? window.innerWidth : window.innerWidth / 2,
|
||||
height: window.innerHeight / 2,
|
||||
};
|
||||
|
||||
const config = {
|
||||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
},
|
||||
scene: {
|
||||
preload: preload,
|
||||
create: create,
|
||||
update: update
|
||||
}
|
||||
};
|
||||
// backgroundImage.png
|
||||
const game = new Phaser.Game(config);
|
||||
const customWidth = window.innerWidth;
|
||||
const customHeight = window.innerHeight;
|
||||
let firstLayer, secondLayer, thirdLayer;
|
||||
let graphics;
|
||||
let isDrawing = false;
|
||||
|
||||
if(isMobile){
|
||||
cloudeSize = 200;
|
||||
cloudHeight = 340;
|
||||
canvasScale = 0.14
|
||||
canvasHeight = 35;
|
||||
letterHeight = 90;
|
||||
letterScale = 1;
|
||||
backgroundScale = 0.8;
|
||||
sunScale = 0.1;
|
||||
sunScalePlus = 0.15;
|
||||
sunWidth = 70;
|
||||
sunHeight = 70;
|
||||
beanieScale = 0.35;
|
||||
beanieScalePlus = 0.38;
|
||||
beanieWidth = 135;
|
||||
beanieHeight = 170;
|
||||
animatedUHeight = 32;
|
||||
} else{
|
||||
cloudeSize = 500;
|
||||
cloudHeight = 250;
|
||||
canvasScale = 0.195;
|
||||
canvasHeight = 20;
|
||||
letterHeight = 50;
|
||||
letterScale = 1;
|
||||
backgroundScale = 1;
|
||||
sunScale = 0.2;
|
||||
sunScalePlus = 0.25;
|
||||
sunWidth = 200;
|
||||
sunHeight = 100;
|
||||
beanieScale = 0.4;
|
||||
beanieScalePlus = 0.44;
|
||||
beanieWidth = 200;
|
||||
beanieHeight = 245;
|
||||
animatedUHeight = 20;
|
||||
}
|
||||
// let hideButton;
|
||||
|
||||
function preload() {
|
||||
this.load.video('animatedU', '/assets/animated-letter/capital_u.mp4');
|
||||
this.load.svg('letterU', '/assets/capital-letter/u.svg');
|
||||
this.load.svg('layer1', '/assets/capital-letter/u.svg');
|
||||
this.load.audio('audioOne', '/assets/audio/tall-down-curve-up.mp3');
|
||||
this.load.image('topLogo', '/assets/top_logo.png');
|
||||
this.load.svg('succesImage', '/assets/svg/tick.svg');
|
||||
this.load.svg('hintImage', '/assets/svg/hint.svg');
|
||||
this.load.svg('handPointer', '/assets/svg/hand.svg');
|
||||
this.load.image('backgroundImage', '/assets/bg6.png');
|
||||
this.load.image('cloud', '/assets/cloud.png');
|
||||
this.load.image('canvas', '/assets/canvas4.png');
|
||||
this.load.image('beanie', '/assets/beanieImage.png');
|
||||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
}
|
||||
|
||||
function create() {
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : U", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
// this.add.image(customWidth / 2, 50, 'cloud').setDepth(1.9);
|
||||
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
const sun = this.add.sprite(customWidth - sunWidth, sunHeight, 'sun').setScale(sunScale).setDepth(-1.9);
|
||||
const beanie = this.add.sprite(customWidth / 2 - beanieWidth, customHeight / 2 - beanieHeight, 'beanie').setScale(beanieScale).setDepth(1.9);
|
||||
|
||||
|
||||
const scaleFactor = sunScalePlus; // Scale factor (2 means double the size)
|
||||
const duration = 3000; // Duration of the animation in milliseconds
|
||||
|
||||
// Create a scaling tween
|
||||
this.tweens.add({
|
||||
targets: sun,
|
||||
scaleX: scaleFactor,
|
||||
scaleY: scaleFactor,
|
||||
duration: duration,
|
||||
ease: 'Linear',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const beaniescaleFactor = beanieScalePlus; // Scale factor (2 means double the size)
|
||||
const beanieduration = 2500;
|
||||
this.tweens.add({
|
||||
targets: beanie,
|
||||
scaleX: beaniescaleFactor + 0.004,
|
||||
scaleY: beaniescaleFactor,
|
||||
duration: beanieduration,
|
||||
ease: 'Redial',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const backgroundImages = this.add.image(customWidth / 2, customHeight /2, 'backgroundImage').setDepth(-2).setScale(backgroundScale);
|
||||
this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'letterU').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2 + 90, customHeight / 2 + letterHeight, 'letterU').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'animatedU').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
maskGraphics.fillRect(customWidth / 2 - (canvas.width * canvasScale) / 2, customHeight / 2 + canvasHeight - (canvas.height * canvasScale) / 2, canvas.width * canvasScale, canvas.height * canvasScale);
|
||||
const mask = maskGraphics.createGeometryMask();
|
||||
|
||||
|
||||
|
||||
let hideButton = this.add.text(customWidth / 2 - 65, customHeight / 1.1, "Let`s Do", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(customWidth / 2 - 50, customHeight / 1.1, "Help!", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 20;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : U', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
const animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedUHeight, 'animatedU').setDepth(2).setScale(0.73);
|
||||
|
||||
// Play the video
|
||||
animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
||||
// You can set additional properties for the video, such as loop and mute:
|
||||
animatedLetter.setLoop(true); // Loop the video
|
||||
animatedLetter.setMute(false); // Unmute the video
|
||||
animatedLetter.on('complete', function () {
|
||||
// Video playback is complete
|
||||
// You can add your code here for what to do when the video finishes.
|
||||
});
|
||||
|
||||
let textX, textY;
|
||||
|
||||
firstLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Tall Down Curve Up',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
firstLayer.setAlpha(0.5);
|
||||
firstLayer.setInteractive({ draggable: true });
|
||||
|
||||
|
||||
|
||||
// Add these variables to keep track of start points
|
||||
let firstDragStartPoint = { x: 0, y: 0 };
|
||||
|
||||
// ...
|
||||
|
||||
// Add this code for firstLayer
|
||||
firstLayer.on('dragstart', (pointer) => {
|
||||
firstDragStartPoint.x = pointer.x;
|
||||
firstDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
firstLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(firstDragStartPoint.x, firstDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 50) {
|
||||
|
||||
firstTextLayer.setVisible(false);
|
||||
firstLayer.setAlpha(1);
|
||||
} else {
|
||||
firstLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
graphics.moveTo(pointer.x, pointer.y);
|
||||
});
|
||||
|
||||
this.input.on('pointerup', function () {
|
||||
isDrawing = false;
|
||||
});
|
||||
|
||||
this.input.on('pointermove', function (pointer) {
|
||||
if (!isDrawing) return;
|
||||
|
||||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
318
src/pages/capital-letter/V.astro
Normal file
318
src/pages/capital-letter/V.astro
Normal file
@@ -0,0 +1,318 @@
|
||||
---
|
||||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script is:inline>
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
width: isMobile ? window.innerWidth : window.innerWidth / 2,
|
||||
height: window.innerHeight / 2,
|
||||
};
|
||||
|
||||
const config = {
|
||||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
},
|
||||
scene: {
|
||||
preload: preload,
|
||||
create: create,
|
||||
update: update
|
||||
}
|
||||
};
|
||||
// backgroundImage.png
|
||||
const game = new Phaser.Game(config);
|
||||
const customWidth = window.innerWidth;
|
||||
const customHeight = window.innerHeight;
|
||||
let firstLayer, secondLayer;
|
||||
let graphics;
|
||||
let isDrawing = false;
|
||||
|
||||
if(isMobile){
|
||||
cloudeSize = 200;
|
||||
cloudHeight = 340;
|
||||
canvasScale = 0.14
|
||||
canvasHeight = 35;
|
||||
letterHeight = 58;
|
||||
letterScale = 0.85;
|
||||
backgroundScale = 0.8;
|
||||
sunScale = 0.1;
|
||||
sunScalePlus = 0.15;
|
||||
sunWidth = 70;
|
||||
sunHeight = 70;
|
||||
beanieScale = 0.35;
|
||||
beanieScalePlus = 0.38;
|
||||
beanieWidth = 135;
|
||||
beanieHeight = 170;
|
||||
animatedVHeight = 32;
|
||||
} else{
|
||||
cloudeSize = 500;
|
||||
cloudHeight = 250;
|
||||
canvasScale = 0.195;
|
||||
canvasHeight = 20;
|
||||
letterHeight = 50;
|
||||
letterScale = 1;
|
||||
backgroundScale = 1;
|
||||
sunScale = 0.2;
|
||||
sunScalePlus = 0.25;
|
||||
sunWidth = 200;
|
||||
sunHeight = 100;
|
||||
beanieScale = 0.4;
|
||||
beanieScalePlus = 0.44;
|
||||
beanieWidth = 200;
|
||||
beanieHeight = 245;
|
||||
animatedVHeight = 20;
|
||||
}
|
||||
// let hideButton;
|
||||
|
||||
function preload() {
|
||||
this.load.video('animatedV', '/assets/animated-letter/capital_v.mp4');
|
||||
this.load.svg('letterV', '/assets/capital-letter/v.svg');
|
||||
this.load.svg('layer1', '/assets/capital-letter/v_l1.svg');
|
||||
this.load.svg('layer2', '/assets/capital-letter/v_l2.svg');
|
||||
this.load.audio('audioOne', '/assets/audio/slant.mp3');
|
||||
this.load.image('topLogo', '/assets/top_logo.png');
|
||||
this.load.svg('succesImage', '/assets/svg/tick.svg');
|
||||
this.load.svg('hintImage', '/assets/svg/hint.svg');
|
||||
this.load.svg('handPointer', '/assets/svg/hand.svg');
|
||||
this.load.image('backgroundImage', '/assets/bg6.png');
|
||||
this.load.image('cloud', '/assets/cloud.png');
|
||||
this.load.image('canvas', '/assets/canvas4.png');
|
||||
this.load.image('beanie', '/assets/beanieImage.png');
|
||||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
}
|
||||
|
||||
function create() {
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : V", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
// this.add.image(customWidth / 2, 50, 'cloud').setDepth(1.9);
|
||||
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
const sun = this.add.sprite(customWidth - sunWidth, sunHeight, 'sun').setScale(sunScale).setDepth(-1.9);
|
||||
const beanie = this.add.sprite(customWidth / 2 - beanieWidth, customHeight / 2 - beanieHeight, 'beanie').setScale(beanieScale).setDepth(1.9);
|
||||
|
||||
|
||||
const scaleFactor = sunScalePlus; // Scale factor (2 means double the size)
|
||||
const duration = 3000; // Duration of the animation in milliseconds
|
||||
|
||||
// Create a scaling tween
|
||||
this.tweens.add({
|
||||
targets: sun,
|
||||
scaleX: scaleFactor,
|
||||
scaleY: scaleFactor,
|
||||
duration: duration,
|
||||
ease: 'Linear',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const beaniescaleFactor = beanieScalePlus; // Scale factor (2 means double the size)
|
||||
const beanieduration = 2500;
|
||||
this.tweens.add({
|
||||
targets: beanie,
|
||||
scaleX: beaniescaleFactor + 0.004,
|
||||
scaleY: beaniescaleFactor,
|
||||
duration: beanieduration,
|
||||
ease: 'Redial',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const backgroundImages = this.add.image(customWidth / 2, customHeight /2, 'backgroundImage').setDepth(-2).setScale(backgroundScale);
|
||||
this.add.image(customWidth / 2 + 30, customHeight / 2 + letterHeight, 'letterV').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'letterV').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'animatedV').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
maskGraphics.fillRect(customWidth / 2 - (canvas.width * canvasScale) / 2, customHeight / 2 + canvasHeight - (canvas.height * canvasScale) / 2, canvas.width * canvasScale, canvas.height * canvasScale);
|
||||
const mask = maskGraphics.createGeometryMask();
|
||||
|
||||
|
||||
|
||||
let hideButton = this.add.text(customWidth / 2 - 65, customHeight / 1.1, "Let`s Do", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(customWidth / 2 - 50, customHeight / 1.1, "Help!", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 20;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : V', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
const animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedVHeight, 'animatedV').setDepth(2).setScale(0.73);
|
||||
|
||||
// Play the video
|
||||
animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
||||
// You can set additional properties for the video, such as loop and mute:
|
||||
animatedLetter.setLoop(true); // Loop the video
|
||||
animatedLetter.setMute(false); // Unmute the video
|
||||
animatedLetter.on('complete', function () {
|
||||
// Video playback is complete
|
||||
// You can add your code here for what to do when the video finishes.
|
||||
});
|
||||
|
||||
let textX, textY;
|
||||
|
||||
firstLayer = this.add.image(customWidth / 2 + 30, customHeight / 2 + letterHeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Slant',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
firstLayer.setAlpha(0.5);
|
||||
firstLayer.setInteractive({ draggable: true });
|
||||
|
||||
secondLayer = this.add.image(customWidth / 2 + 30, customHeight / 2 + letterHeight, 'layer2').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
const secondTextLayer = this.add.text(textX, textY, '2. Slant',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioTwoAudio = this.sound.add('audioOne');
|
||||
secondTextLayer.setVisible(false);
|
||||
secondLayer.setDepth(1);
|
||||
secondLayer.setAlpha(0.5);
|
||||
secondLayer.setInteractive({ draggable: true });
|
||||
secondLayer.setVisible(false);
|
||||
|
||||
|
||||
// Add these variables to keep track of start points
|
||||
let firstDragStartPoint = { x: 0, y: 0 };
|
||||
let secondDragStartPoint = { x: 0, y: 0 };
|
||||
|
||||
// ...
|
||||
|
||||
// Add this code for firstLayer
|
||||
firstLayer.on('dragstart', (pointer) => {
|
||||
firstDragStartPoint.x = pointer.x;
|
||||
firstDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
firstLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(firstDragStartPoint.x, firstDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
|
||||
firstTextLayer.setVisible(false);
|
||||
secondTextLayer.setVisible(true);
|
||||
audioTwoAudio.play();
|
||||
secondLayer.setVisible(true);
|
||||
firstLayer.setAlpha(1);
|
||||
secondLayer.setAlpha(0.5);
|
||||
} else {
|
||||
firstLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
``
|
||||
// Repeat the above code for secondLayer and thirdLayer
|
||||
|
||||
// Add this code for secondLayer
|
||||
secondLayer.on('dragstart', (pointer) => {
|
||||
secondDragStartPoint.x = pointer.x;
|
||||
secondDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
secondLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(secondDragStartPoint.x, secondDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >=100) {
|
||||
secondTextLayer.setVisible(false);
|
||||
secondLayer.setAlpha(1);
|
||||
} else {
|
||||
secondLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
graphics.moveTo(pointer.x, pointer.y);
|
||||
console.log("Start Position", pointer.x, pointer.y)
|
||||
});
|
||||
|
||||
this.input.on('pointerup', function () {
|
||||
isDrawing = false;
|
||||
});
|
||||
|
||||
this.input.on('pointermove', function (pointer) {
|
||||
if (!isDrawing) return;
|
||||
|
||||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
385
src/pages/capital-letter/W.astro
Normal file
385
src/pages/capital-letter/W.astro
Normal file
@@ -0,0 +1,385 @@
|
||||
---
|
||||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script is:inline>
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
width: isMobile ? window.innerWidth : window.innerWidth / 2,
|
||||
height: window.innerHeight / 2,
|
||||
};
|
||||
|
||||
const config = {
|
||||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
},
|
||||
scene: {
|
||||
preload: preload,
|
||||
create: create,
|
||||
update: update
|
||||
}
|
||||
};
|
||||
// backgroundImage.png
|
||||
const game = new Phaser.Game(config);
|
||||
const customWidth = window.innerWidth;
|
||||
const customHeight = window.innerHeight;
|
||||
let firstLayer, secondLayer, thirdLayer, fourthLayer;
|
||||
let graphics;
|
||||
let isDrawing = false;
|
||||
|
||||
if(isMobile){
|
||||
cloudeSize = 200;
|
||||
cloudHeight = 340;
|
||||
canvasScale = 0.14
|
||||
canvasHeight = 35;
|
||||
letterHeight = 60;
|
||||
letterScale = 0.85;
|
||||
backgroundScale = 0.8;
|
||||
sunScale = 0.1;
|
||||
sunScalePlus = 0.15;
|
||||
sunWidth = 70;
|
||||
sunHeight = 70;
|
||||
beanieScale = 0.35;
|
||||
beanieScalePlus = 0.38;
|
||||
beanieWidth = 135;
|
||||
beanieHeight = 170;
|
||||
animatedWHeight = 32;
|
||||
} else{
|
||||
cloudeSize = 500;
|
||||
cloudHeight = 250;
|
||||
canvasScale = 0.195;
|
||||
canvasHeight = 20;
|
||||
letterHeight = 50;
|
||||
letterScale = 1;
|
||||
backgroundScale = 1;
|
||||
sunScale = 0.2;
|
||||
sunScalePlus = 0.25;
|
||||
sunWidth = 200;
|
||||
sunHeight = 100;
|
||||
beanieScale = 0.4;
|
||||
beanieScalePlus = 0.44;
|
||||
beanieWidth = 200;
|
||||
beanieHeight = 245;
|
||||
animatedWHeight = 20;
|
||||
}
|
||||
function preload() {
|
||||
this.load.video('animatedW', '/assets/animated-letter/capital_w.mp4');
|
||||
this.load.svg('letterW', '/assets/capital-letter/w.svg');
|
||||
this.load.svg('layer1', '/assets/capital-letter/w_l1.svg');
|
||||
this.load.svg('layer2', '/assets/capital-letter/w_l2.svg');
|
||||
this.load.svg('layer3', '/assets/capital-letter/w_l3.svg');
|
||||
this.load.svg('layer4', '/assets/capital-letter/w_l4.svg');
|
||||
this.load.audio('audioOne', '/assets/audio/slant.mp3');
|
||||
this.load.image('topLogo', '/assets/top_logo.png');
|
||||
this.load.svg('succesImage', '/assets/svg/tick.svg');
|
||||
this.load.svg('hintImage', '/assets/svg/hint.svg');
|
||||
this.load.svg('handPointer', '/assets/svg/hand.svg');
|
||||
this.load.image('backgroundImage', '/assets/bg6.png');
|
||||
this.load.image('cloud', '/assets/cloud.png');
|
||||
this.load.image('canvas', '/assets/canvas4.png');
|
||||
this.load.image('beanie', '/assets/beanieImage.png');
|
||||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
}
|
||||
|
||||
function create() {
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : W", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
// this.add.image(customWidth / 2, 50, 'cloud').setDepth(1.9);
|
||||
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
const sun = this.add.sprite(customWidth - sunWidth, sunHeight, 'sun').setScale(sunScale).setDepth(-1.9);
|
||||
const beanie = this.add.sprite(customWidth / 2 - beanieWidth, customHeight / 2 - beanieHeight, 'beanie').setScale(beanieScale).setDepth(1.9);
|
||||
|
||||
|
||||
const scaleFactor = sunScalePlus; // Scale factor (2 means double the size)
|
||||
const duration = 3000; // Duration of the animation in milliseconds
|
||||
|
||||
// Create a scaling tween
|
||||
this.tweens.add({
|
||||
targets: sun,
|
||||
scaleX: scaleFactor,
|
||||
scaleY: scaleFactor,
|
||||
duration: duration,
|
||||
ease: 'Linear',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const beaniescaleFactor = beanieScalePlus; // Scale factor (2 means double the size)
|
||||
const beanieduration = 2500;
|
||||
this.tweens.add({
|
||||
targets: beanie,
|
||||
scaleX: beaniescaleFactor + 0.004,
|
||||
scaleY: beaniescaleFactor,
|
||||
duration: beanieduration,
|
||||
ease: 'Redial',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const backgroundImages = this.add.image(customWidth / 2, customHeight /2, 'backgroundImage').setDepth(-2).setScale(backgroundScale);
|
||||
this.add.image(customWidth / 2 - 20, customHeight / 2 + letterHeight, 'letterW').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2 - 20, customHeight / 2 + letterHeight, 'letterW').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'animatedW').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
maskGraphics.fillRect(customWidth / 2 - (canvas.width * canvasScale) / 2, customHeight / 2 + canvasHeight - (canvas.height * canvasScale) / 2, canvas.width * canvasScale, canvas.height * canvasScale);
|
||||
const mask = maskGraphics.createGeometryMask();
|
||||
|
||||
|
||||
|
||||
let hideButton = this.add.text(customWidth / 2 - 65, customHeight / 1.1, "Let`s Do", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(customWidth / 2 - 50, customHeight / 1.1, "Help!", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 20;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : W', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
const animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedWHeight, 'animatedW').setDepth(2).setScale(0.73);
|
||||
|
||||
// Play the video
|
||||
animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
||||
// You can set additional properties for the video, such as loop and mute:
|
||||
animatedLetter.setLoop(true); // Loop the video
|
||||
animatedLetter.setMute(false); // Unmute the video
|
||||
animatedLetter.on('complete', function () {
|
||||
// Video playback is complete
|
||||
// You can add your code here for what to do when the video finishes.
|
||||
});
|
||||
|
||||
let textX, textY;
|
||||
|
||||
firstLayer = this.add.image(customWidth / 2 - 20, customHeight / 2 + letterHeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Slant',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
firstLayer.setAlpha(0.5);
|
||||
firstLayer.setInteractive({ draggable: true });
|
||||
|
||||
secondLayer = this.add.image(customWidth / 2 - 20, customHeight / 2 + letterHeight, 'layer2').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
const secondTextLayer = this.add.text(textX, textY, '2. Slant',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioTwoAudio = this.sound.add('audioOne');
|
||||
secondTextLayer.setVisible(false);
|
||||
secondLayer.setDepth(1);
|
||||
secondLayer.setAlpha(0.5);
|
||||
secondLayer.setInteractive({ draggable: true });
|
||||
secondLayer.setVisible(false);
|
||||
|
||||
thirdLayer = this.add.image(customWidth / 2 - 20, customHeight / 2 + letterHeight, 'layer3').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 3 : customWidth * 0.75;
|
||||
const thirdTextLayer = this.add.text(textX, textY, '3. Slant', { font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioThreeAudio = this.sound.add('audioOne');
|
||||
thirdTextLayer.setVisible(false);
|
||||
thirdLayer.setDepth(1.1);
|
||||
// thirdLayer.setScale(1.15);
|
||||
thirdLayer.setAlpha(0.5);
|
||||
thirdLayer.setInteractive({ draggable: true });
|
||||
thirdLayer.setVisible(false);
|
||||
|
||||
fourthLayer = this.add.image(customWidth / 2 - 20, customHeight / 2 + letterHeight, 'layer4').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 3 : customWidth * 0.75;
|
||||
const fourthTextLayer = this.add.text(textX, textY, '4. Slant', { font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioFourthAudio = this.sound.add('audioOne');
|
||||
fourthTextLayer.setVisible(false);
|
||||
fourthLayer.setDepth(1.1);
|
||||
// fourthLayer.setScale(1.15);
|
||||
fourthLayer.setAlpha(0.5);
|
||||
fourthLayer.setInteractive({ draggable: true });
|
||||
fourthLayer.setVisible(false);
|
||||
|
||||
// Add these variables to keep track of start points
|
||||
let firstDragStartPoint = { x: 0, y: 0 };
|
||||
let secondDragStartPoint = { x: 0, y: 0 };
|
||||
let thirdDragStartPoint = { x: 0, y: 0 };
|
||||
let fourthDragStartPoint = { x: 0, y: 0 };
|
||||
|
||||
// Add this code for firstLayer
|
||||
firstLayer.on('dragstart', (pointer) => {
|
||||
firstDragStartPoint.x = pointer.x;
|
||||
firstDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
firstLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(firstDragStartPoint.x, firstDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
firstTextLayer.setVisible(false);
|
||||
secondTextLayer.setVisible(true);
|
||||
audioTwoAudio.play();
|
||||
secondLayer.setVisible(true);
|
||||
firstLayer.setAlpha(1);
|
||||
secondLayer.setAlpha(0.5);
|
||||
thirdLayer.setAlpha(0.5);
|
||||
fourthLayer.setAlpha(0.5);
|
||||
} else {
|
||||
firstLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
// Repeat the above code for secondLayer and thirdLayer
|
||||
|
||||
// Add this code for secondLayer
|
||||
secondLayer.on('dragstart', (pointer) => {
|
||||
secondDragStartPoint.x = pointer.x;
|
||||
secondDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
secondLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(secondDragStartPoint.x, secondDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
secondTextLayer.setVisible(false);
|
||||
thirdTextLayer.setVisible(true);
|
||||
audioThreeAudio.play();
|
||||
thirdLayer.setVisible(true);
|
||||
secondLayer.setAlpha(1);
|
||||
thirdLayer.setAlpha(0.5);
|
||||
fourthLayer.setAlpha(0.5);
|
||||
} else {
|
||||
secondLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
// Add this code for thirdLayer
|
||||
thirdLayer.on('dragstart', (pointer) => {
|
||||
thirdDragStartPoint.x = pointer.x;
|
||||
thirdDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
thirdLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(thirdDragStartPoint.x, thirdDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
thirdLayer.setAlpha(1);
|
||||
thirdTextLayer.setVisible(false);
|
||||
fourthTextLayer.setVisible(true);
|
||||
fourthLayer.setVisible(true);
|
||||
fourthLayer.setAlpha(0.5);
|
||||
audioFourthAudio.play();
|
||||
} else {
|
||||
thirdLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
fourthLayer.on('dragstart', (pointer) => {
|
||||
fourthDragStartPoint.x = pointer.x;
|
||||
fourthDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
fourthLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(fourthDragStartPoint.x, fourthDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
fourthLayer.setAlpha(1);
|
||||
fourthTextLayer.setVisible(false);
|
||||
} else {
|
||||
fourthLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
graphics.moveTo(pointer.x, pointer.y);
|
||||
console.log("Start Position", pointer.x, pointer.y)
|
||||
});
|
||||
|
||||
this.input.on('pointerup', function () {
|
||||
isDrawing = false;
|
||||
});
|
||||
|
||||
this.input.on('pointermove', function (pointer) {
|
||||
if (!isDrawing) return;
|
||||
|
||||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
|
||||
// Start Position 626 317
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
319
src/pages/capital-letter/X.astro
Normal file
319
src/pages/capital-letter/X.astro
Normal file
@@ -0,0 +1,319 @@
|
||||
---
|
||||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script is:inline>
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
width: isMobile ? window.innerWidth : window.innerWidth / 2,
|
||||
height: window.innerHeight / 2,
|
||||
};
|
||||
|
||||
const config = {
|
||||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
},
|
||||
scene: {
|
||||
preload: preload,
|
||||
create: create,
|
||||
update: update
|
||||
}
|
||||
};
|
||||
// backgroundImage.png
|
||||
const game = new Phaser.Game(config);
|
||||
const customWidth = window.innerWidth;
|
||||
const customHeight = window.innerHeight;
|
||||
let firstLayer, secondLayer;
|
||||
let graphics;
|
||||
let isDrawing = false;
|
||||
|
||||
if(isMobile){
|
||||
cloudeSize = 200;
|
||||
cloudHeight = 340;
|
||||
canvasScale = 0.14
|
||||
canvasHeight = 35;
|
||||
letterHeight = 58;
|
||||
letterScale = 0.85;
|
||||
backgroundScale = 0.8;
|
||||
sunScale = 0.1;
|
||||
sunScalePlus = 0.15;
|
||||
sunWidth = 70;
|
||||
sunHeight = 70;
|
||||
beanieScale = 0.35;
|
||||
beanieScalePlus = 0.38;
|
||||
beanieWidth = 135;
|
||||
beanieHeight = 170;
|
||||
animatedXHeight = 32;
|
||||
} else{
|
||||
cloudeSize = 500;
|
||||
cloudHeight = 250;
|
||||
canvasScale = 0.195;
|
||||
canvasHeight = 20;
|
||||
letterHeight = 50;
|
||||
letterScale = 1;
|
||||
backgroundScale = 1;
|
||||
sunScale = 0.2;
|
||||
sunScalePlus = 0.25;
|
||||
sunWidth = 200;
|
||||
sunHeight = 100;
|
||||
beanieScale = 0.4;
|
||||
beanieScalePlus = 0.44;
|
||||
beanieWidth = 200;
|
||||
beanieHeight = 245;
|
||||
animatedXHeight = 20;
|
||||
}
|
||||
// let hideButton;
|
||||
|
||||
function preload() {
|
||||
this.load.video('animatedX', '/assets/animated-letter/capital_x.mp4');
|
||||
this.load.svg('letterX', '/assets/capital-letter/x.svg');
|
||||
this.load.svg('layer1', '/assets/capital-letter/x_l1.svg');
|
||||
this.load.svg('layer2', '/assets/capital-letter/x_l2.svg');
|
||||
this.load.audio('audioOne', '/assets/audio/slant.mp3');
|
||||
this.load.audio('audioTwo', '/assets/audio/cross.mp3');
|
||||
this.load.image('topLogo', '/assets/top_logo.png');
|
||||
this.load.svg('succesImage', '/assets/svg/tick.svg');
|
||||
this.load.svg('hintImage', '/assets/svg/hint.svg');
|
||||
this.load.svg('handPointer', '/assets/svg/hand.svg');
|
||||
this.load.image('backgroundImage', '/assets/bg6.png');
|
||||
this.load.image('cloud', '/assets/cloud.png');
|
||||
this.load.image('canvas', '/assets/canvas4.png');
|
||||
this.load.image('beanie', '/assets/beanieImage.png');
|
||||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
}
|
||||
|
||||
function create() {
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : X", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
// this.add.image(customWidth / 2, 50, 'cloud').setDepth(1.9);
|
||||
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
const sun = this.add.sprite(customWidth - sunWidth, sunHeight, 'sun').setScale(sunScale).setDepth(-1.9);
|
||||
const beanie = this.add.sprite(customWidth / 2 - beanieWidth, customHeight / 2 - beanieHeight, 'beanie').setScale(beanieScale).setDepth(1.9);
|
||||
|
||||
|
||||
const scaleFactor = sunScalePlus; // Scale factor (2 means double the size)
|
||||
const duration = 3000; // Duration of the animation in milliseconds
|
||||
|
||||
// Create a scaling tween
|
||||
this.tweens.add({
|
||||
targets: sun,
|
||||
scaleX: scaleFactor,
|
||||
scaleY: scaleFactor,
|
||||
duration: duration,
|
||||
ease: 'Linear',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const beaniescaleFactor = beanieScalePlus; // Scale factor (2 means double the size)
|
||||
const beanieduration = 2500;
|
||||
this.tweens.add({
|
||||
targets: beanie,
|
||||
scaleX: beaniescaleFactor + 0.004,
|
||||
scaleY: beaniescaleFactor,
|
||||
duration: beanieduration,
|
||||
ease: 'Redial',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const backgroundImages = this.add.image(customWidth / 2, customHeight /2, 'backgroundImage').setDepth(-2).setScale(backgroundScale);
|
||||
this.add.image(customWidth / 2 + 30, customHeight / 2 + letterHeight, 'letterX').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'letterX').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'animatedX').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
maskGraphics.fillRect(customWidth / 2 - (canvas.width * canvasScale) / 2, customHeight / 2 + canvasHeight - (canvas.height * canvasScale) / 2, canvas.width * canvasScale, canvas.height * canvasScale);
|
||||
const mask = maskGraphics.createGeometryMask();
|
||||
|
||||
|
||||
|
||||
let hideButton = this.add.text(customWidth / 2 - 65, customHeight / 1.1, "Let`s Do", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(customWidth / 2 - 50, customHeight / 1.1, "Help!", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 20;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : X', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
const animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedXHeight, 'animatedX').setDepth(2).setScale(0.73);
|
||||
|
||||
// Play the video
|
||||
animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
||||
// You can set additional properties for the video, such as loop and mute:
|
||||
animatedLetter.setLoop(true); // Loop the video
|
||||
animatedLetter.setMute(false); // Unmute the video
|
||||
animatedLetter.on('complete', function () {
|
||||
// Video playback is complete
|
||||
// You can add your code here for what to do when the video finishes.
|
||||
});
|
||||
|
||||
let textX, textY;
|
||||
|
||||
firstLayer = this.add.image(customWidth / 2 + 30, customHeight / 2 + letterHeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Slant',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
firstLayer.setAlpha(0.5);
|
||||
firstLayer.setInteractive({ draggable: true });
|
||||
|
||||
secondLayer = this.add.image(customWidth / 2 + 30, customHeight / 2 + letterHeight, 'layer2').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
const secondTextLayer = this.add.text(textX, textY, '2. Cross',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioTwoAudio = this.sound.add('audioTwo');
|
||||
secondTextLayer.setVisible(false);
|
||||
secondLayer.setDepth(1);
|
||||
secondLayer.setAlpha(0.5);
|
||||
secondLayer.setInteractive({ draggable: true });
|
||||
secondLayer.setVisible(false);
|
||||
|
||||
|
||||
// Add these variables to keep track of start points
|
||||
let firstDragStartPoint = { x: 0, y: 0 };
|
||||
let secondDragStartPoint = { x: 0, y: 0 };
|
||||
|
||||
// ...
|
||||
|
||||
// Add this code for firstLayer
|
||||
firstLayer.on('dragstart', (pointer) => {
|
||||
firstDragStartPoint.x = pointer.x;
|
||||
firstDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
firstLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(firstDragStartPoint.x, firstDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
|
||||
firstTextLayer.setVisible(false);
|
||||
secondTextLayer.setVisible(true);
|
||||
audioTwoAudio.play();
|
||||
secondLayer.setVisible(true);
|
||||
firstLayer.setAlpha(1);
|
||||
secondLayer.setAlpha(0.5);
|
||||
} else {
|
||||
firstLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
``
|
||||
// Repeat the above code for secondLayer and thirdLayer
|
||||
|
||||
// Add this code for secondLayer
|
||||
secondLayer.on('dragstart', (pointer) => {
|
||||
secondDragStartPoint.x = pointer.x;
|
||||
secondDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
secondLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(secondDragStartPoint.x, secondDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >=100) {
|
||||
secondTextLayer.setVisible(false);
|
||||
secondLayer.setAlpha(1);
|
||||
} else {
|
||||
secondLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
graphics.moveTo(pointer.x, pointer.y);
|
||||
console.log("Start Position", pointer.x, pointer.y)
|
||||
});
|
||||
|
||||
this.input.on('pointerup', function () {
|
||||
isDrawing = false;
|
||||
});
|
||||
|
||||
this.input.on('pointermove', function (pointer) {
|
||||
if (!isDrawing) return;
|
||||
|
||||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
351
src/pages/capital-letter/Y.astro
Normal file
351
src/pages/capital-letter/Y.astro
Normal file
@@ -0,0 +1,351 @@
|
||||
---
|
||||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script is:inline>
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
width: isMobile ? window.innerWidth : window.innerWidth / 2,
|
||||
height: window.innerHeight / 2,
|
||||
};
|
||||
|
||||
const config = {
|
||||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
},
|
||||
scene: {
|
||||
preload: preload,
|
||||
create: create,
|
||||
update: update
|
||||
}
|
||||
};
|
||||
// backgroundImage.png
|
||||
const game = new Phaser.Game(config);
|
||||
const customWidth = window.innerWidth;
|
||||
const customHeight = window.innerHeight;
|
||||
let firstLayer, secondLayer, thirdLayer;
|
||||
let graphics;
|
||||
let isDrawing = false;
|
||||
// let x = 100;
|
||||
|
||||
// // Use x
|
||||
// console.log(x);
|
||||
|
||||
if(isMobile){
|
||||
cloudeSize = 200;
|
||||
cloudHeight = 340;
|
||||
canvasScale = 0.14
|
||||
canvasHeight = 35;
|
||||
letterHeight = 70;
|
||||
letterScale = 1;
|
||||
backgroundScale = 0.8;
|
||||
sunScale = 0.1;
|
||||
sunScalePlus = 0.15;
|
||||
sunWidth = 70;
|
||||
sunHeight = 70;
|
||||
beanieScale = 0.35;
|
||||
beanieScalePlus = 0.365;
|
||||
beanieWidth = 135;
|
||||
beanieHeight = 170;
|
||||
animatedYHeight = 35;
|
||||
animatedYScale = 0.65;
|
||||
} else{
|
||||
cloudeSize = 500;
|
||||
cloudHeight = 250;
|
||||
canvasScale = 0.195;
|
||||
canvasHeight = 20;
|
||||
letterHeight = 50;
|
||||
letterScale = 1;
|
||||
backgroundScale = 1;
|
||||
sunScale = 0.2;
|
||||
sunScalePlus = 0.25;
|
||||
sunWidth = 200;
|
||||
sunHeight = 100;
|
||||
beanieScale = 0.4;
|
||||
beanieScalePlus = 0.45;
|
||||
beanieWidth = 200;
|
||||
beanieHeight = 255;
|
||||
animatedYHeight = 20;
|
||||
animatedYScale = 0.73;
|
||||
}
|
||||
function preload() {
|
||||
this.load.video('animatedY', '/assets/animated-letter/capital_y.mp4');
|
||||
this.load.svg('letterY', '/assets/capital-letter/y.svg');
|
||||
this.load.svg('layer1', '/assets/capital-letter/y_l1.svg');
|
||||
this.load.svg('layer2', '/assets/capital-letter/y_l2.svg');
|
||||
this.load.svg('layer3', '/assets/capital-letter/y_l3.svg');
|
||||
this.load.audio('audioOne', '/assets/audio/slant-right.mp3');
|
||||
this.load.audio('audioTwo', '/assets/audio/slant-left.mp3');
|
||||
this.load.audio('audioThree', '/assets/audio/down.mp3');
|
||||
this.load.image('topLogo', '/assets/top_logo.png');
|
||||
this.load.svg('succesImage', '/assets/svg/tick.svg');
|
||||
this.load.svg('hintImage', '/assets/svg/hint.svg');
|
||||
this.load.svg('handPointer', '/assets/svg/hand.svg');
|
||||
this.load.image('backgroundImage', '/assets/bg6.png');
|
||||
this.load.image('cloud', '/assets/cloud.png');
|
||||
this.load.image('canvas', '/assets/canvas4.png');
|
||||
// this.load.image('beanie', '/assets/beanie.png');
|
||||
this.load.image('beanie', '/assets/beanieImage.png');
|
||||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
}
|
||||
|
||||
function create() {
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : Y", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
const sun = this.add.sprite(customWidth - sunWidth, sunHeight, 'sun').setScale(sunScale).setDepth(-1.9);
|
||||
const beanie = this.add.sprite(customWidth / 2 - beanieWidth, customHeight / 2 - beanieHeight, 'beanie').setScale(beanieScale).setDepth(1.9);
|
||||
|
||||
|
||||
const scaleFactor = sunScalePlus; // Scale factor (2 means double the size)
|
||||
const duration = 3000; // Duration of the animation in milliseconds
|
||||
|
||||
// Create a scaling tween
|
||||
this.tweens.add({
|
||||
targets: sun,
|
||||
scaleX: scaleFactor,
|
||||
scaleY: scaleFactor,
|
||||
duration: duration,
|
||||
ease: 'Linear',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const beaniescaleFactor = beanieScalePlus; // Scale factor (2 means double the size)
|
||||
const beanieduration = 2500;
|
||||
this.tweens.add({
|
||||
targets: beanie,
|
||||
scaleX: beaniescaleFactor + 0.004,
|
||||
scaleY: beaniescaleFactor,
|
||||
duration: beanieduration,
|
||||
ease: 'Redial',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const backgroundImages = this.add.image(customWidth / 2, customHeight /2, 'backgroundImage').setDepth(-2).setScale(backgroundScale);
|
||||
this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'letterY').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'letterY').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'animatedY').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
maskGraphics.fillRect(customWidth / 2 - (canvas.width * canvasScale) / 2, customHeight / 2 + canvasHeight - (canvas.height * canvasScale) / 2, canvas.width * canvasScale, canvas.height * canvasScale);
|
||||
const mask = maskGraphics.createGeometryMask();
|
||||
|
||||
|
||||
|
||||
let hideButton = this.add.text(customWidth / 2 - 65, customHeight / 1.1, "Let`s Do", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(customWidth / 2 - 50, customHeight / 1.1, "Help!", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 20;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : Y', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
const animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedYHeight, 'animatedY').setDepth(2).setScale(animatedYScale);
|
||||
|
||||
// Play the video
|
||||
animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
||||
// You can set additional properties for the video, such as loop and mute:
|
||||
animatedLetter.setLoop(true); // Loop the video
|
||||
animatedLetter.setMute(false); // Unmute the video
|
||||
animatedLetter.on('complete', function () {
|
||||
// add function after end video;
|
||||
});
|
||||
|
||||
let textX, textY;
|
||||
|
||||
firstLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Slant Right',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
firstLayer.setAlpha(0.5);
|
||||
firstLayer.setInteractive({ draggable: true });
|
||||
|
||||
secondLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer2').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
const secondTextLayer = this.add.text(textX, textY, '2. Slant Left',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioTwoAudio = this.sound.add('audioTwo');
|
||||
secondTextLayer.setVisible(false);
|
||||
secondLayer.setDepth(1);
|
||||
secondLayer.setAlpha(0.5);
|
||||
secondLayer.setInteractive({ draggable: true });
|
||||
secondLayer.setVisible(false);
|
||||
|
||||
thirdLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer3').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 3 : customWidth * 0.75;
|
||||
const thirdTextLayer = this.add.text(textX, textY, '3. Down', { font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioThreeAudio = this.sound.add('audioThree');
|
||||
thirdTextLayer.setVisible(false);
|
||||
thirdLayer.setDepth(1.1);
|
||||
// thirdLayer.setScale(1.15);
|
||||
thirdLayer.setAlpha(0.5);
|
||||
thirdLayer.setInteractive({ draggable: true });
|
||||
thirdLayer.setVisible(false);
|
||||
|
||||
// Add these variables to keep track of start points
|
||||
let firstDragStartPoint = { x: 0, y: 0 };
|
||||
let secondDragStartPoint = { x: 0, y: 0 };
|
||||
let thirdDragStartPoint = { x: 0, y: 0 };
|
||||
|
||||
// ...
|
||||
|
||||
// Add this code for firstLayer
|
||||
firstLayer.on('dragstart', (pointer) => {
|
||||
firstDragStartPoint.x = pointer.x;
|
||||
firstDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
firstLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(firstDragStartPoint.x, firstDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
|
||||
firstTextLayer.setVisible(false);
|
||||
secondTextLayer.setVisible(true);
|
||||
audioTwoAudio.play();
|
||||
secondLayer.setVisible(true);
|
||||
firstLayer.setAlpha(1);
|
||||
secondLayer.setAlpha(0.5);
|
||||
thirdLayer.setAlpha(0.5);
|
||||
} else {
|
||||
firstLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
secondLayer.on('dragstart', (pointer) => {
|
||||
secondDragStartPoint.x = pointer.x;
|
||||
secondDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
secondLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(secondDragStartPoint.x, secondDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
secondTextLayer.setVisible(false);
|
||||
thirdTextLayer.setVisible(true);
|
||||
audioThreeAudio.play();
|
||||
thirdLayer.setVisible(true);
|
||||
secondLayer.setAlpha(1);
|
||||
thirdLayer.setAlpha(0.5);
|
||||
} else {
|
||||
secondLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
// Add this code for thirdLayer
|
||||
thirdLayer.on('dragstart', (pointer) => {
|
||||
thirdDragStartPoint.x = pointer.x;
|
||||
thirdDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
thirdLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(thirdDragStartPoint.x, thirdDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
thirdLayer.setAlpha(1);
|
||||
thirdTextLayer.setVisible(false);
|
||||
} else {
|
||||
thirdLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
graphics.moveTo(pointer.x, pointer.y);
|
||||
// console.log("Start Position", pointer.x, pointer.y)
|
||||
});
|
||||
|
||||
this.input.on('pointerup', function () {
|
||||
isDrawing = false;
|
||||
});
|
||||
|
||||
this.input.on('pointermove', function (pointer) {
|
||||
if (!isDrawing) return;
|
||||
|
||||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
}
|
||||
|
||||
function update() {
|
||||
}
|
||||
|
||||
</script>
|
||||
350
src/pages/capital-letter/Z.astro
Normal file
350
src/pages/capital-letter/Z.astro
Normal file
@@ -0,0 +1,350 @@
|
||||
---
|
||||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script is:inline>
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
width: isMobile ? window.innerWidth : window.innerWidth / 2,
|
||||
height: window.innerHeight / 2,
|
||||
};
|
||||
|
||||
const config = {
|
||||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
},
|
||||
scene: {
|
||||
preload: preload,
|
||||
create: create,
|
||||
update: update
|
||||
}
|
||||
};
|
||||
// backgroundImage.png
|
||||
const game = new Phaser.Game(config);
|
||||
const customWidth = window.innerWidth;
|
||||
const customHeight = window.innerHeight;
|
||||
let firstLayer, secondLayer, thirdLayer;
|
||||
let graphics;
|
||||
let isDrawing = false;
|
||||
// let x = 100;
|
||||
|
||||
// // Use x
|
||||
// console.log(x);
|
||||
|
||||
if(isMobile){
|
||||
cloudeSize = 200;
|
||||
cloudHeight = 340;
|
||||
canvasScale = 0.14
|
||||
canvasHeight = 35;
|
||||
letterHeight = 70;
|
||||
letterScale = 1;
|
||||
backgroundScale = 0.8;
|
||||
sunScale = 0.1;
|
||||
sunScalePlus = 0.15;
|
||||
sunWidth = 70;
|
||||
sunHeight = 70;
|
||||
beanieScale = 0.35;
|
||||
beanieScalePlus = 0.365;
|
||||
beanieWidth = 135;
|
||||
beanieHeight = 170;
|
||||
animatedZHeight = 35;
|
||||
animatedZScale = 0.65;
|
||||
} else{
|
||||
cloudeSize = 500;
|
||||
cloudHeight = 250;
|
||||
canvasScale = 0.195;
|
||||
canvasHeight = 20;
|
||||
letterHeight = 50;
|
||||
letterScale = 1;
|
||||
backgroundScale = 1;
|
||||
sunScale = 0.2;
|
||||
sunScalePlus = 0.25;
|
||||
sunWidth = 200;
|
||||
sunHeight = 100;
|
||||
beanieScale = 0.4;
|
||||
beanieScalePlus = 0.45;
|
||||
beanieWidth = 200;
|
||||
beanieHeight = 255;
|
||||
animatedZHeight = 20;
|
||||
animatedZScale = 0.73;
|
||||
}
|
||||
function preload() {
|
||||
this.load.video('animatedZ', '/assets/animated-letter/capital_z.mp4');
|
||||
this.load.svg('letterZ', '/assets/capital-letter/z.svg');
|
||||
this.load.svg('layer1', '/assets/capital-letter/z_l1.svg');
|
||||
this.load.svg('layer2', '/assets/capital-letter/z_l2.svg');
|
||||
this.load.svg('layer3', '/assets/capital-letter/z_l3.svg');
|
||||
this.load.audio('audioOne', '/assets/audio/slide.mp3');
|
||||
this.load.audio('audioTwo', '/assets/audio/slant.mp3');
|
||||
this.load.image('topLogo', '/assets/top_logo.png');
|
||||
this.load.svg('succesImage', '/assets/svg/tick.svg');
|
||||
this.load.svg('hintImage', '/assets/svg/hint.svg');
|
||||
this.load.svg('handPointer', '/assets/svg/hand.svg');
|
||||
this.load.image('backgroundImage', '/assets/bg6.png');
|
||||
this.load.image('cloud', '/assets/cloud.png');
|
||||
this.load.image('canvas', '/assets/canvas4.png');
|
||||
// this.load.image('beanie', '/assets/beanie.png');
|
||||
this.load.image('beanie', '/assets/beanieImage.png');
|
||||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
}
|
||||
|
||||
function create() {
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : Z", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
const sun = this.add.sprite(customWidth - sunWidth, sunHeight, 'sun').setScale(sunScale).setDepth(-1.9);
|
||||
const beanie = this.add.sprite(customWidth / 2 - beanieWidth, customHeight / 2 - beanieHeight, 'beanie').setScale(beanieScale).setDepth(1.9);
|
||||
|
||||
|
||||
const scaleFactor = sunScalePlus; // Scale factor (2 means double the size)
|
||||
const duration = 3000; // Duration of the animation in milliseconds
|
||||
|
||||
// Create a scaling tween
|
||||
this.tweens.add({
|
||||
targets: sun,
|
||||
scaleX: scaleFactor,
|
||||
scaleY: scaleFactor,
|
||||
duration: duration,
|
||||
ease: 'Linear',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const beaniescaleFactor = beanieScalePlus; // Scale factor (2 means double the size)
|
||||
const beanieduration = 2500;
|
||||
this.tweens.add({
|
||||
targets: beanie,
|
||||
scaleX: beaniescaleFactor + 0.004,
|
||||
scaleY: beaniescaleFactor,
|
||||
duration: beanieduration,
|
||||
ease: 'Redial',
|
||||
yoyo: true, // Makes the animation play in reverse
|
||||
repeat: -1 // Repeat indefinitely
|
||||
});
|
||||
const backgroundImages = this.add.image(customWidth / 2, customHeight /2, 'backgroundImage').setDepth(-2).setScale(backgroundScale);
|
||||
this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'letterZ').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'letterZ').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'animatedZ').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
maskGraphics.fillRect(customWidth / 2 - (canvas.width * canvasScale) / 2, customHeight / 2 + canvasHeight - (canvas.height * canvasScale) / 2, canvas.width * canvasScale, canvas.height * canvasScale);
|
||||
const mask = maskGraphics.createGeometryMask();
|
||||
|
||||
|
||||
|
||||
let hideButton = this.add.text(customWidth / 2 - 65, customHeight / 1.1, "Let`s Do", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(customWidth / 2 - 50, customHeight / 1.1, "Help!", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 20;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : Z', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
const animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedZHeight, 'animatedZ').setDepth(2).setScale(animatedZScale);
|
||||
|
||||
// Play the video
|
||||
animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
||||
// You can set additional properties for the video, such as loop and mute:
|
||||
animatedLetter.setLoop(true); // Loop the video
|
||||
animatedLetter.setMute(false); // Unmute the video
|
||||
animatedLetter.on('complete', function () {
|
||||
// add function after end video;
|
||||
});
|
||||
|
||||
let textX, textY;
|
||||
|
||||
firstLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Slide',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
firstLayer.setAlpha(0.5);
|
||||
firstLayer.setInteractive({ draggable: true });
|
||||
|
||||
secondLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer2').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
const secondTextLayer = this.add.text(textX, textY, '2. Slant',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioTwoAudio = this.sound.add('audioTwo');
|
||||
secondTextLayer.setVisible(false);
|
||||
secondLayer.setDepth(1);
|
||||
secondLayer.setAlpha(0.5);
|
||||
secondLayer.setInteractive({ draggable: true });
|
||||
secondLayer.setVisible(false);
|
||||
|
||||
thirdLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer3').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 3 : customWidth * 0.75;
|
||||
const thirdTextLayer = this.add.text(textX, textY, '3. Slide', { font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const audioThreeAudio = this.sound.add('audioOne');
|
||||
thirdTextLayer.setVisible(false);
|
||||
thirdLayer.setDepth(1.1);
|
||||
// thirdLayer.setScale(1.15);
|
||||
thirdLayer.setAlpha(0.5);
|
||||
thirdLayer.setInteractive({ draggable: true });
|
||||
thirdLayer.setVisible(false);
|
||||
|
||||
// Add these variables to keep track of start points
|
||||
let firstDragStartPoint = { x: 0, y: 0 };
|
||||
let secondDragStartPoint = { x: 0, y: 0 };
|
||||
let thirdDragStartPoint = { x: 0, y: 0 };
|
||||
|
||||
// ...
|
||||
|
||||
// Add this code for firstLayer
|
||||
firstLayer.on('dragstart', (pointer) => {
|
||||
firstDragStartPoint.x = pointer.x;
|
||||
firstDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
firstLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(firstDragStartPoint.x, firstDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
|
||||
firstTextLayer.setVisible(false);
|
||||
secondTextLayer.setVisible(true);
|
||||
audioTwoAudio.play();
|
||||
secondLayer.setVisible(true);
|
||||
firstLayer.setAlpha(1);
|
||||
secondLayer.setAlpha(0.5);
|
||||
thirdLayer.setAlpha(0.5);
|
||||
} else {
|
||||
firstLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
secondLayer.on('dragstart', (pointer) => {
|
||||
secondDragStartPoint.x = pointer.x;
|
||||
secondDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
secondLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(secondDragStartPoint.x, secondDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
secondTextLayer.setVisible(false);
|
||||
thirdTextLayer.setVisible(true);
|
||||
audioThreeAudio.play();
|
||||
thirdLayer.setVisible(true);
|
||||
secondLayer.setAlpha(1);
|
||||
thirdLayer.setAlpha(0.5);
|
||||
} else {
|
||||
secondLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
// Add this code for thirdLayer
|
||||
thirdLayer.on('dragstart', (pointer) => {
|
||||
thirdDragStartPoint.x = pointer.x;
|
||||
thirdDragStartPoint.y = pointer.y;
|
||||
});
|
||||
|
||||
thirdLayer.on('drag', (pointer) => {
|
||||
const distance = Phaser.Math.Distance.Between(thirdDragStartPoint.x, thirdDragStartPoint.y, pointer.x, pointer.y);
|
||||
|
||||
if (distance >= 100) {
|
||||
thirdLayer.setAlpha(1);
|
||||
thirdTextLayer.setVisible(false);
|
||||
} else {
|
||||
thirdLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
graphics.moveTo(pointer.x, pointer.y);
|
||||
// console.log("Start Position", pointer.x, pointer.y)
|
||||
});
|
||||
|
||||
this.input.on('pointerup', function () {
|
||||
isDrawing = false;
|
||||
});
|
||||
|
||||
this.input.on('pointermove', function (pointer) {
|
||||
if (!isDrawing) return;
|
||||
|
||||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
}
|
||||
|
||||
function update() {
|
||||
}
|
||||
|
||||
</script>
|
||||
55
src/pages/capital-letter/tt.astro
Normal file
55
src/pages/capital-letter/tt.astro
Normal file
@@ -0,0 +1,55 @@
|
||||
---
|
||||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script is:inline>
|
||||
// Define the sprite sheet properties
|
||||
const frameWidth = 32; // Adjust based on your sprite sheet
|
||||
const frameHeight = 32; // Adjust based on your sprite sheet
|
||||
const numFrames = 8; // Adjust based on the number of frames in your sprite sheet
|
||||
const frameRate = 10; // Adjust the speed of the animation
|
||||
|
||||
// Preload function to load assets
|
||||
function preload() {
|
||||
this.load.spritesheet('playerWalk', '/assets/beanieImage.png', {
|
||||
frameWidth: frameWidth,
|
||||
frameHeight: frameHeight
|
||||
});
|
||||
}
|
||||
|
||||
// Create function to set up the game
|
||||
function create() {
|
||||
// Create an animation using the loaded sprite sheet
|
||||
this.anims.create({
|
||||
key: 'walk',
|
||||
frames: this.anims.generateFrameNumbers('playerWalk', { start: 0, end: numFrames }),
|
||||
frameRate: frameRate,
|
||||
repeat: -1
|
||||
});
|
||||
|
||||
// Create a sprite and play the animation
|
||||
const player = this.add.sprite(100, 100, 'playerWalk');
|
||||
player.play('walk');
|
||||
}
|
||||
|
||||
// Load the Phaser game
|
||||
const config = {
|
||||
type: Phaser.AUTO,
|
||||
width: 800,
|
||||
height: 600,
|
||||
scene: {
|
||||
preload,
|
||||
create
|
||||
}
|
||||
};
|
||||
|
||||
const game = new Phaser.Game(config);
|
||||
|
||||
|
||||
</script>
|
||||
Reference in New Issue
Block a user