Add: animal sprite sheet

This commit is contained in:
2018-11-12 10:34:37 +09:00
parent 72e0c95992
commit 99ca77d950
35 changed files with 125 additions and 34 deletions
+51 -24
View File
@@ -1,12 +1,16 @@
function Animal(type, x, y) {
function Animal(type, index, x, y) {
this.animalType = type;
this.sprite = null;
this.posX = x;
this.posY = y;
this.sprite = game.add.sprite(this.posX, this.posY); //, "snail_run1"); // this.spriteFrameNames.run1);
// this.sprite = game.add.sprite(this.posX, this.posY); //, "snail_run1"); // this.spriteFrameNames.run1);
this.sprite = game.add.sprite(this.posX, this.posY, "animals");
this.sprite.anchor.set(0.5);
this.sprite.animations.add("stand", [index * 2]);
this.sprite.animations.play("stand");
this.sprite.animations.add("run", [index * 2, index * 2 + 1]);
}
@@ -17,14 +21,15 @@ Animal.prototype.setScale = function(value) {
Animal.prototype.setIconSprite = function(species) {
this.setSpecies(species);
this.spriteFrameNames = this.loadSpriteNames();
this.sprite.loadTexture(this.spriteFrameNames.run1);
// this.spriteFrameNames = this.loadSpriteNames();
// this.sprite.loadTexture(this.spriteFrameNames.run1);
}
Animal.prototype.setSpecies = function(species) {
this.species = species;
}
/*
Animal.prototype.loadSpriteNames = function() {
let spriteNames = {};
@@ -35,6 +40,7 @@ Animal.prototype.loadSpriteNames = function() {
return spriteNames;
}
*/
Animal.prototype.setAlpha = function(value) {
this.sprite.alpha = value;
@@ -44,14 +50,15 @@ Animal.prototype.setAlpha = function(value) {
Animal.prototype.tweenAnimation = function(animationType) {
switch(animationType) {
case Animal.ANIMATION_TYPE_CHANGE:
this.sprite.width = 200;
this.sprite.height = 200;
game.add.tween(this.sprite).to( { width: 150, height: 150 }, 500, Phaser.Easing.Bounce.Out, true);
this.sprite.width = 100;
this.sprite.height = 100;
game.add.tween(this.sprite).to( { width: 50, height: 50 }, 500, Phaser.Easing.Bounce.Out, true);
break;
case Animal.ANIMATION_TYPE_DAMAGE:
this.sprite.width = 200;
game.add.tween(this.sprite).to( { width: 150 }, 500, Phaser.Easing.Bounce.In, true);
this.sprite.width = 100;
this.sprite.height = 50;
game.add.tween(this.sprite).to( { width: 50 }, 500, Phaser.Easing.Bounce.In, true);
// game.add.tween(this.sprite).to( { width: 50 }, 500, Phaser.Easing.Elastic.Out, true);
break;
@@ -59,23 +66,28 @@ Animal.prototype.tweenAnimation = function(animationType) {
}
Animal.prototype.setupAnimation = function() {
this.spriteFrameNames = this.loadSpriteNames();
this.playingSpriteFrameName = this.spriteFrameNames.run1;
this.animationFrameID = 1;
this.animationSpeedSec = 1000 / this.species.runningFPS;
// this.spriteFrameNames = this.loadSpriteNames();
// this.playingSpriteFrameName = this.spriteFrameNames.run1;
// this.animationFrameID = 1;
// this.animationSpeedSec = 1000 / this.species.runningFPS;
this.stopAnimation();
this.animateionUpdate();
// this.animateionUpdate();
}
Animal.prototype.startAnimation = function(species) {
this.sprite.animations.play("run", 5, true);
/*
this.setSpecies(species);
this.setupAnimation();
if(this.timerEvent === null)
this.timerEvent = game.time.events.loop(this.animationSpeedSec, this.animateionUpdate, this);
*/
}
/*
Animal.prototype.animateionUpdate = function() {
this.animationFrameID = 1 - this.animationFrameID;
@@ -87,12 +99,17 @@ Animal.prototype.animateionUpdate = function() {
this.sprite.width = 150;
this.sprite.height = 150;
}
*/
Animal.prototype.stopAnimation = function() {
this.sprite.animations.stop("run");
/*
if(this.timerEvent !== null) {
game.time.events.remove(this.timerEvent);
this.timerEvent = null;
}
*/
}
@@ -113,8 +130,12 @@ Animal.typingCount = function(speciesData, gameType) {
}
Animal.loadResources = function() {
game.load.spritesheet('animals', '../../../resources/image/character/animal/animals.png', 50, 50);
game.load.image('snail_shadow', '../../../resources/image/character/animal/snail/shadow.png');
/*
game.load.image('snail_icon', '../../../resources/image/character/animal/snail/run2.png');
game.load.image('snail_run1', '../../../resources/image/character/animal/snail/run1.png');
game.load.image('snail_run2', '../../../resources/image/character/animal/snail/run2.png');
@@ -154,6 +175,7 @@ Animal.loadResources = function() {
game.load.image('eagle_icon', '../../../resources/image/character/animal/eagle/run2.png');
game.load.image('eagle_run1', '../../../resources/image/character/animal/eagle/run1.png');
game.load.image('eagle_run2', '../../../resources/image/character/animal/eagle/run2.png');
*/
}
@@ -168,16 +190,21 @@ Animal.ANIMATION_TYPE_DAMAGE = 1;
Animal.SPECIES_DATA = [
{ "species" : "snail", "runningFPS" : 1.1, "practiceTypingCount" : 0, "testTypingCount" : 0 },
{ "species" : "turtle", "runningFPS" : 2.2, "practiceTypingCount" : 5, "testTypingCount" : 20 },
{ "species" : "cat", "runningFPS" : 3.3, "practiceTypingCount" : 10, "testTypingCount" : 50 },
{ "species" : "lion", "runningFPS" : 4.4, "practiceTypingCount" : 15, "testTypingCount" : 100 },
{ "species" : "rabbit", "runningFPS" : 5.5, "practiceTypingCount" : 20, "testTypingCount" : 200 },
{ "species" : "ostrich", "runningFPS" : 7.7, "practiceTypingCount" : 25, "testTypingCount" : 300 },
{ "species" : "horse", "runningFPS" : 9.9, "practiceTypingCount" : 30, "testTypingCount" : 400 },
{ "species" : "dog", "runningFPS" : 12.2, "practiceTypingCount" : 35, "testTypingCount" : 500 },
{ "species" : "cheetah", "runningFPS" : 16, "practiceTypingCount" : 40, "testTypingCount" : 600 },
{ "species" : "eagle", "runningFPS" : 20, "practiceTypingCount" : 50, "testTypingCount" : 700 }
{ "species" : "snail", "fps" : 1.1, "practiceTypingCount" : 0, "testTypingCount" : 0 },
{ "species" : "turtle", "fps" : 2.2, "practiceTypingCount" : 5, "testTypingCount" : 20 },
{ "species" : "chick", "fps" : 3.3, "practiceTypingCount" : 10, "testTypingCount" : 40 },
{ "species" : "mouse", "fps" : 4.4, "practiceTypingCount" : 15, "testTypingCount" : 70 },
{ "species" : "chicken", "fps" : 5.5, "practiceTypingCount" : 20, "testTypingCount" : 100 },
{ "species" : "pig", "fps" : 7.7, "practiceTypingCount" : 25, "testTypingCount" : 150 },
{ "species" : "cat", "fps" : 9.9, "practiceTypingCount" : 30, "testTypingCount" : 200 },
{ "species" : "deer", "fps" : 12.2, "practiceTypingCount" : 40, "testTypingCount" : 250 },
{ "species" : "kangaroo", "fps" : 16, "practiceTypingCount" : 50, "testTypingCount" : 300 },
{ "species" : "rabbit", "fps" : 20, "practiceTypingCount" : 60, "testTypingCount" : 350 },
{ "species" : "dog", "fps" : 20, "practiceTypingCount" : 80, "testTypingCount" : 400 },
{ "species" : "zebra", "fps" : 20, "practiceTypingCount" : 100, "testTypingCount" : 450 },
{ "species" : "ostrich", "fps" : 20, "practiceTypingCount" : 120, "testTypingCount" : 500 },
{ "species" : "lion", "fps" : 20, "practiceTypingCount" : 140, "testTypingCount" : 600 },
{ "species" : "cheetah", "fps" : 20, "practiceTypingCount" : 160, "testTypingCount" : 700 }
];
Animal.SPRITE_NAMES = {
+7 -4
View File
@@ -4,14 +4,15 @@ function AnimalList(y) {
var animalCount = Animal.SPECIES_DATA.length;
var lineWidth = GAME_SCREEN_SIZE.x - AnimalList.MARGIN_X * 2;
console.log("lineWidth : " + lineWidth);
// console.log("lineWidth : " + lineWidth);
var offsetAnimal = lineWidth / (animalCount - 1);
console.log("animalCount : " + animalCount);
console.log("offsetAnimal : " + offsetAnimal);
// console.log("animalCount : " + animalCount);
// console.log("offsetAnimal : " + offsetAnimal);
for(var i = 0; i < animalCount; i++) {
this.animals[i] = new Animal(
Animal.TYPE_ICON,
i,
AnimalList.MARGIN_X + offsetAnimal * i,
y
);
@@ -19,7 +20,9 @@ function AnimalList(y) {
}
this.activeAnimalIndex = 0;
// this.activate(this.activeAnimalIndex);
this.activate(this.activeAnimalIndex);
this.tweenAnimation(Animal.ANIMATION_TYPE_DAMAGE);
}
AnimalList.prototype.activate = function(index) {
@@ -55,5 +58,5 @@ AnimalList.prototype.tweenAnimation = function(animationType) {
}
AnimalList.MARGIN_X = 160;
AnimalList.MARGIN_X = 100;
AnimalList.ALPHA_INACTIVE = 0.1;
+48 -2
View File
@@ -22,21 +22,67 @@ TypingTextManager.prototype.getShuffledArray = function(arr) {
return Phaser.ArrayUtils.shuffle(arr);
}
TypingTextManager.prototype.fillLeftRightBasicKey = function() {
var length = this.contents.length;
// console.log(length);
for(var i = length - 1; i > -1; i--) {
var char = this.contents[i];
// console.log(char);
if(this.isKoreanConsonant(char)) {
this.contents.splice(i + 1, 0, "ㅏ");
} else if(this.isKoreanVowel(char)) {
this.contents.splice(i, 0, "ㄹ");
}
}
}
TypingTextManager.prototype.isKoreanConsonant = function(char) {
if(char.length != 1)
return false;
if(TypingTextManager.rCho.indexOf(char) > -1)
return true;
else if(TypingTextManager.rJong.indexOf(char) > -1)
return;
}
TypingTextManager.prototype.isKoreanVowel = function(char) {
if(char.length != 1)
return false;
if(TypingTextManager.rJung.indexOf(char) > -1)
return true;
}
TypingTextManager.prototype.makePracticeContents = function(arr, repeatCount) {
this.init();
this.add(arr);
for(var i = 0; i < repeatCount; i++) {
this.add(this.getShuffledArray(arr));
}
this.fillLeftRightBasicKey();
}
TypingTextManager.prototype.makeTestContents = function(arr) {
this.init();
this.add(this.getShuffledArray(arr));
this.add(this.getShuffledArray());
}
TypingTextManager.shuffledArray = function(arr) {
return Phaser.ArrayUtils.shuffle(arr);
}
}
TypingTextManager.rCho =
[ "ㄱ", "ㄲ", "ㄴ", "ㄷ", "ㄸ", "ㄹ", "ㅁ", "ㅂ", "ㅃ", "ㅅ", "ㅆ", "ㅇ", "ㅈ", "ㅉ",
"ㅊ", "ㅋ", "ㅌ", "ㅍ", "ㅎ" ];
TypingTextManager.rJung =
[ "ㅏ", "ㅐ", "ㅑ", "ㅒ", "ㅓ", "ㅔ", "ㅕ", "ㅖ", "ㅗ", "ㅘ", "ㅙ", "ㅚ", "ㅛ", "ㅜ",
"ㅝ", "ㅞ", "ㅟ", "ㅠ", "ㅡ", "ㅢ", "ㅣ" ];
TypingTextManager.rJong =
[ "", "ㄱ", "ㄲ", "ㄳ", "ㄴ", "ㄵ", "ㄶ", "ㄷ", "ㄹ", "ㄺ", "ㄻ", "ㄼ", "ㄽ", "ㄾ",
"ㄿ", "ㅀ", "ㅁ", "ㅂ", "ㅄ", "ㅅ", "ㅆ", "ㅇ", "ㅈ", "ㅊ", "ㅋ", "ㅌ",
"ㅍ", "ㅎ" ];
+4 -4
View File
@@ -30,13 +30,13 @@ var TypingPractice = {
}));
this.animalList = new AnimalList(100);
// typing content
var typingContentBG = new TypingContentBG();
typingContentBG.makePracticeContentBG();
this.animalList = new AnimalList(100);
var TYPING_CONTENT_Y = 200;
textStyleBasic.font = "bold 84px Times New Roman";
@@ -405,7 +405,7 @@ TypingPractice.TYPING_COUNT_PLUS_ENTER = 1;
TypingPractice.OFFSET_RIGHT_ALIGN = 10;
TypingPractice.STAGE_TIMER_SEC = 30;
TypingPractice.STAGE_TIMER_SEC = 60;
TypingPractice.COLOR_CONTENT_INPUT = "#dddddd";
TypingPractice.COLOR_BRACKET = "#dddd70";