Commit 61c69f2b by william

feat: add slider images at index page

parent 6bcf80b4
assets/images/classroom.png

297 KB | W: | H:

assets/images/classroom.png

205 KB | W: | H:

assets/images/classroom.png
assets/images/classroom.png
assets/images/classroom.png
assets/images/classroom.png
  • 2-up
  • Swipe
  • Onion skin
{
"ver": "1.0.0",
"uuid": "74666af9-3b83-4c79-bb74-e64662a7a91c",
"uuid": "0e671404-8643-4f9b-b078-3f8446678813",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"subMetas": {
"classroom": {
"ver": "1.0.3",
"uuid": "1b29ad23-8777-436b-a7aa-5c7869ce1389",
"rawTextureUuid": "74666af9-3b83-4c79-bb74-e64662a7a91c",
"uuid": "f591fb94-46c8-48d7-8734-08b854cf1cf9",
"rawTextureUuid": "0e671404-8643-4f9b-b078-3f8446678813",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
......@@ -17,9 +17,9 @@
"trimX": 0,
"trimY": 0,
"width": 750,
"height": 1052,
"height": 1086,
"rawWidth": 750,
"rawHeight": 1052,
"rawHeight": 1086,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
......
{
"ver": "1.0.0",
"uuid": "c1edaf9b-1d22-4985-9a24-b434a1a935bd",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"subMetas": {
"coming": {
"ver": "1.0.3",
"uuid": "4dc33e6a-f362-45a9-ba81-09b423a784cd",
"rawTextureUuid": "c1edaf9b-1d22-4985-9a24-b434a1a935bd",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -0.5,
"offsetY": -1.5,
"trimX": 0,
"trimY": 10,
"width": 317,
"height": 235,
"rawWidth": 318,
"rawHeight": 252,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "1.0.0",
"uuid": "99ab9e92-0590-468c-829d-9727377075d6",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.0.0",
"uuid": "b6d7d820-6cd3-44b3-8b40-54693bedcde8",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"subMetas": {
"heart": {
"ver": "1.0.3",
"uuid": "203a4498-7630-44ec-b721-b71e8b43723c",
"rawTextureUuid": "b6d7d820-6cd3-44b3-8b40-54693bedcde8",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": -0.5,
"trimX": 20,
"trimY": 5,
"width": 412,
"height": 43,
"rawWidth": 452,
"rawHeight": 52,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "1.0.0",
"uuid": "17d58126-1062-4aa6-b063-4cdec3c5fd99",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"subMetas": {
"icon-clock": {
"ver": "1.0.3",
"uuid": "3a67a3d3-9dc3-4a7d-81d0-ecbe373d913e",
"rawTextureUuid": "17d58126-1062-4aa6-b063-4cdec3c5fd99",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 2,
"trimY": 2,
"width": 64,
"height": 64,
"rawWidth": 68,
"rawHeight": 68,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "1.0.0",
"uuid": "a8a2c2e9-ea49-41b7-b49d-32fc93adc909",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"subMetas": {
"icon-points": {
"ver": "1.0.3",
"uuid": "29ceedec-bce6-4b8e-b3ac-7f6caba37028",
"rawTextureUuid": "a8a2c2e9-ea49-41b7-b49d-32fc93adc909",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 6,
"trimY": 4,
"width": 180,
"height": 184,
"rawWidth": 192,
"rawHeight": 192,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "1.0.0",
"uuid": "7d060af6-8545-4836-a745-6f4cd72b710f",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"subMetas": {
"slider1": {
"ver": "1.0.3",
"uuid": "6ba718e6-8958-40cf-8686-358a6f812baa",
"rawTextureUuid": "7d060af6-8545-4836-a745-6f4cd72b710f",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -0.5,
"offsetY": 0.5,
"trimX": 0,
"trimY": 0,
"width": 685,
"height": 329,
"rawWidth": 686,
"rawHeight": 330,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "1.0.0",
"uuid": "292c0f2f-cac9-4bac-8530-3cbfb82a5426",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"subMetas": {
"slider2": {
"ver": "1.0.3",
"uuid": "f409b697-49a0-46d5-9077-8e11bf45a204",
"rawTextureUuid": "292c0f2f-cac9-4bac-8530-3cbfb82a5426",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 676,
"height": 248,
"rawWidth": 676,
"rawHeight": 248,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "1.0.0",
"uuid": "1c06c629-8a84-429b-abf3-4909a7ce6f79",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"subMetas": {
"slider3": {
"ver": "1.0.3",
"uuid": "f4f49579-65f6-4f9f-abef-74f31468e7d5",
"rawTextureUuid": "1c06c629-8a84-429b-abf3-4909a7ce6f79",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -0.5,
"offsetY": 0.5,
"trimX": 0,
"trimY": 0,
"width": 685,
"height": 311,
"rawWidth": 686,
"rawHeight": 312,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "1.0.0",
"uuid": "b1bac8d5-c52e-4a7b-b68b-43d6eb8b43e2",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"subMetas": {
"teacher": {
"ver": "1.0.3",
"uuid": "09d89bc6-37a2-46c9-9a55-020b4eb52067",
"rawTextureUuid": "b1bac8d5-c52e-4a7b-b68b-43d6eb8b43e2",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": -2.5,
"trimX": 0,
"trimY": 5,
"width": 136,
"height": 387,
"rawWidth": 136,
"rawHeight": 392,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
......@@ -13,12 +13,6 @@ cc.Class({
type: cc.Node,
},
// subtitle节点
subtitle: {
default: null,
type: cc.Node,
},
// btn_start节点
start_btn: {
default: null,
......@@ -37,53 +31,207 @@ cc.Class({
active: false,
},
// index节点
index: {
default: null,
type: cc.Node,
active: false,
},
// hand节点
hand: {
default: null,
type: cc.Node,
},
// store number节点
score_number: {
default: null,
type: cc.Label,
},
// board节点
board: {
default: null,
type: cc.Node,
active: false,
},
// level节点
level: {
default: null,
type: cc.ProgressBar,
},
// failure节点
failure: {
default: null,
type: cc.Node,
active: false,
},
// success节点
success: {
default: null,
type: cc.Node,
active: false,
},
// success_result节点
success_result: {
default: null,
type: cc.Label,
},
// 背景音乐节点
bgMusic: {
default: null,
type: cc.AudioSource,
},
// slider节点
slider1: {
default: null,
type: cc.Node,
},
slider2: {
default: null,
type: cc.Node,
},
slider3: {
default: null,
type: cc.Node,
}
},
initNode: function() {
var self = this
self.hand.active = true
self.index.active = true
self.success.active = false
},
onLoad: function () {
initData: function() {
// 初始化游戏数据
this.score = 0; // 分数
this.timer = 60; // 每一盘游戏的总时间
this.score = 0; // 分数
this.timer = 10; // 每一盘游戏的总时间
this.leftLife = 3; // 剩余的命条数
this.gameState = "waitting"; // 游戏的状态 waiting(待开始) action(游戏中) stop(被抓) over(分数总结)
this.swivelAnimationTime = 0.5; //转头动画时间 (单向)
this.flirtAnimationTime = 0.5; //摸的动画时间(单向)
this.gameState = 'waiting'; // 游戏的状态 waiting(待开始) action(游戏中) stop(被抓) over(分数总结)
},
onLoad: function () {
this.initData()
// 奖Game组件的实例传入开始按钮
var startBtn = cc.find("index/start_btn", this.node);
var startBtn = cc.find('index/start_btn', this.node);
startBtn.getComponent('Start').game = this;
var teacher = cc.find("teacher", this.node);
// 将Game组件的实例传入teacher
var teacher = cc.find('teacher', this.node);
teacher.getComponent('Teacher').game = this;
// 将Game组件的实例传入hand
var hand = cc.find('hand', this.node)
hand.getComponent('Hand').game = this
// 将Game组件的实例传入playAgain
var successPlayAgain = cc.find('success/playAgain', this.node)
successPlayAgain.getComponent('Restart').game = this
var failurePlayAgain = cc.find('failure/playAgain', this.node)
failurePlayAgain.getComponent('Restart').game = this
// 播放背景音乐
this.playBackgroundMusic()
// 执行轮播图
},
// 更改时间进度条
updateLevelProgress: function() {
if(this.level.progress > 0) {
this.level.progress -= ((1 / this.timer) / 60)
} else {
this.gameOver()
}
if(this.level.progress < 0.8 && this.level.progress > 0.2) {
this.level.barSprite.node.color = {
a: 255,
b: 234,
g: 56,
r: 241
}
} else if (this.level.progress <= 0.2) {
this.level.barSprite.node.color = {
a: 255,
b: 0,
g: 0,
r: 255,
}
}
},
// 添加分数
gainScore: function() {
this.score += 1;
this.score_number.string = this.score.toString();
},
// 被抓检测
getCaught: function() {
var isFlirting = this.hand.getComponent('Hand').isFlirting
var isSwiveling = this.teacher.getComponent('Teacher').isSwiveling
return isSwiveling && isFlirting
},
// 添加背景音乐
playBackgroundMusic: function() {
this.bgMusic.play()
},
// 游戏帧循环
update: function(dt) {
if (this.gameState === 'action') {
this.updateLevelProgress()
if (this.getCaught()) {
this.gameFail()
}
}
},
// 游戏开始
startGame: function() {
cc.director.loadScene('game')
},
// 游戏暂停
stopGame: function() {
gameFail: function() {
this.success_result.string = this.score.toString()
this.classroom.active = false
this.failure.active = true
this.hand.active = false
this.board.active = false
this.teacher.active = false
this.gameState = 'stop'
},
// 游戏结束
gameOver: function() {
this.success_result.string = this.score.toString()
this.classroom.active = false
this.success.active = true
this.hand.active = false
this.board.active = false
this.teacher.active = false
this.gameState = 'waiting'
},
});
......@@ -53,6 +53,12 @@ cc.Class({
self.isFlirting = false
self.node.runAction(self.endFlirtingAction)
})
self.node.on(cc.Node.EventType.TOUCH_CANCEL, (event) => {
// self.node.on(cc.Node.EventType.MOUSE_UP, (event) => {
self.isFlirting = false
self.node.runAction(self.endFlirtingAction)
})
},
// LIFE-CYCLE CALLBACKS:
......
cc.Class({
extends: cc.Component,
properties: {
},
restartGame: function() {
var self = this;
self.game.startGame()
},
onLoad: function() {
this.node.on('click', this.restartGame, this)
}
});
{
"ver": "1.0.5",
"uuid": "c95b8edc-f3f0-4992-875c-0f8a83dff859",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
// Learn cc.Class:
// - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html
// - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html
// Learn Attribute:
// - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
// - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
// - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html
cc.Class({
extends: cc.Component,
properties: {
slider1: {
default: null,
type: cc.Node,
},
slider2: {
default: null,
type: cc.Node,
},
slider3: {
default: null,
type: cc.Node,
}
},
slider1Action: function() {
return () => {
cc.sequence(
cc.moveTo(2, cc.p(-343, 0)),
cc.moveTo(2, cc.p(343, 0)),
cc.delayTime(2),
)
}
},
slider2Action: function () {
return cc.sequence(
cc.moveTo(2, cc.p(0, 0)),
cc.moveTo(2, cc.p(-343, 0)),
cc.delayTime(4),
)
},
slider3Action: function () {
return cc.sequence(
cc.delayTime(4),
cc.moveTo(2, cc.p(0, 0)),
cc.moveTo(2, cc.p(-343, 0)),
cc.moveTo(2, cc.p(343, 0)),
)
},
// LIFE-CYCLE CALLBACKS:
onLoad () {
// var self = this
// var slider1 = cc.find('slider1', self.node)
// var slider2 = cc.find('slider2', self.node)
// var slider3 = cc.find('slider3', self.node)
this.slider1.runAction(cc.repeatForever(cc.sequence(
cc.delayTime(1),
cc.moveTo(1, cc.p(-343, 0)),
cc.hide(),
cc.moveTo(3, cc.p(343, 0)),
cc.show(),
cc.moveTo(1, cc.p(0, 0))
)))
this.slider2.runAction(cc.repeatForever(cc.sequence(
cc.delayTime(1),
cc.moveTo(1, cc.p(0, 0)),
cc.delayTime(1),
cc.moveTo(1, cc.p(-343, 0)),
cc.hide(),
cc.moveTo(2, cc.p(343, 0)),
cc.show(),
)))
// this.slider2.runAction(this.slider2Action)
this.slider3.runAction(cc.repeatForever(cc.sequence(
cc.hide(),
cc.moveTo(3, cc.p(343, 0)),
cc.show(),
cc.moveTo(1, cc.p(0, 0)),
cc.delayTime(1),
cc.moveTo(1, cc.p(-343, 0)),
)))
},
start () {
},
// update (dt) {},
});
{
"ver": "1.0.5",
"uuid": "818da73c-58a5-433c-9eb7-6ef9fd91fc7c",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
......@@ -8,8 +8,14 @@ cc.Class({
setTouchBtnListener: function () {
var self = this;
self.node.on(cc.Node.EventType.MOUSE_DOWN, function (event) {
self.node.on(cc.Node.EventType.TOUCH_START, function (event) {
self.game.classroom.active = true
self.game.index.active = false
self.game.board.active = true
self.game.teacher.active = true
self.game.level.progress = 1
self.game.gameState = 'action'
self.game.teacher.getComponent("Teacher").startSwivel()
})
},
......
cc.Class({
extends: cc.Component,
properties: {
isSwiveling: false, // 是否回头
totalTime: 45 * 1000, // 总时间, bed
animationTime: 1 * 1000, // 转头过程单位时间, bed
needSwivelCount: 10, // 需要回头的次数
game: {
default: null,
type: cc.Node,
......@@ -20,11 +16,16 @@ cc.Class({
},
onLoad: function() {
this.startSwivel()
// this.startSwivel()
this.isSwiveling = false // 是否回头
this.totalTime = 60 * 1000 // 总时间, bed
this.animationTime = 1 * 1000 // 转头过程单位时间, bed
this.needSwivelCount = 20 // 需要回头的次数
},
swivelAnimation: function() {
var time = this.animationTime / 8 / 1000
var time = this.animationTime / 10 / 1000
var enableSwivel = cc.callFunc(function() {
this.isSwiveling = true
......@@ -34,31 +35,31 @@ cc.Class({
this.isSwiveling = false
}, this)
var coming = cc.find("coming", this.node)
// var coming = cc.find("coming", this.node)
var bigHead = cc.find("big_head", this.node)
var comingAction = cc.sequence(
cc.moveTo(time, cc.p(100, 0)),
cc.delayTime(time),
cc.moveTo(time, cc.p(-50, 0)),
cc.delayTime(time)
)
// var comingAction = cc.sequence(
// cc.moveTo(time, cc.p(100, 0)),
// cc.delayTime(time),
// cc.moveTo(time, cc.p(-50, 0)),
// cc.delayTime(time)
// )
var action = cc.sequence(
cc.delayTime(time * 4), // for coming time
cc.moveTo(time, cc.p(100, 0)),
// cc.delayTime(time * 5), // for coming time
cc.moveTo(5 * time, cc.p(100, 0)),
enableSwivel,
cc.delayTime(4 * time),
cc.moveTo(time, cc.p(0, 0)),
disableSwivel,
)
coming.runAction(comingAction)
// coming.runAction(comingAction)
bigHead.runAction(action)
},
update: function(dt) {
console.log('🐞-checking', this.isSwiveling)
// console.log('🐞-checking', this.isSwiveling)
},
// 获取转头时间的数组, [0.6, 1.2, 2.3, 3.4, 4.8, 5.2, 6.3]
......@@ -78,13 +79,15 @@ cc.Class({
var swivelTimeArray = this.getSwivelTimeArray(this.totalTime, this.needSwivelCount, this.animationTime)
var lastTime
var swivelFunc = (timeArray) => {
const nextTime = timeArray.shift()
if (nextTime) {
var intervel = !!lastTime ? (nextTime - lastTime) : nextTime // 获取下一次的时间间隔
var intervel = !!lastTime ? (nextTime - lastTime) : nextTime // 获取下一次的时间间隔
lastTime = nextTime
this.swivelAnimation()
setTimeout(() => {
this.swivelAnimation()
swivelFunc(timeArray)
}, intervel)
}
......
{
"ver": "1.0.5",
"uuid": "7ddb2772-19ec-4c3c-bf4d-e26a09605838",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment