您的位置:首页 > 移动开发 > 微信开发

贵人礼-中秋微信推广游戏

2016-08-27 16:42 387 查看


项目描述 中秋节推广小游戏 规定时间吃月饼游戏

需求:增加订阅数

我的工作:1. 通过CreateJS给游戏添加音效

2.关注,分享朋友圈功能

3,游戏核心逻辑判断

添加音频 通过SoundJS,

createjs.Sound.registerSound("assets/sound.mp3", "soundname");


createjs.Sound.registerSound( {src:”video/err.mp3”, id:”err”} );

createjs.Sound.registerSound( {src:”video/end.mp3”, id:”end”} );

createjs.Sound.registerSound( {src:”video/tap.mp3”, id:”tap”} );

使用时调用:

createjs.Sound.play("soundname");
createjs.Sound.play("end");


2.关注分享功能

window.shareData = {

“imgUrl”: “images/logo.jpg”,

“timeLineLink”: “http://www.misslays.sinaapp.com/“,

“tTitle”: “中秋就要到,吃月饼大赛开始了!”,

“tContent”: “快来一起吃月饼!”

};

3,游戏核心逻辑判断

function gameTapEvent(e){
if (_gameOver) {
return false;
}
var tar = e.target;
var y = e.clientY || e.targetTouches[0].clientY,
x = (e.clientX || e.targetTouches[0].clientX)-body.offsetLeft,
p = _gameBBList[_gameBBListIndex];
if ( y > touchArea[0] || y < touchArea[1] ) {
return false;
}
if( (p.id==tar.id&&tar.notEmpty) || (p.cell==0&&x<blockSize) || (p.cell==1&&x>blockSize&&x<2*blockSize) || (p.cell==2&&x>2*blockSize&&x<3*blockSize) || (p.cell==3&&x>3*blockSize) ){
if( !_gameStart ){
gameStart();
}
createjs.Sound.play("tap");
tar = document.getElementById(p.id);
tar.className = tar.className.replace(_ttreg, ' tt$1');
_gameBBListIndex++;
_gameScore ++;
gameLayerMoveNextRow();
}else if( _gameStart && !tar.notEmpty ){
createjs.Sound.play("err");
gameOver();
tar.className += ' bad';
}
return false;
}


function gameLayerMoveNextRow(){
for(var i=0; i<GameLayer.length; i++){
var g = GameLayer[i];
g.y += blockSize;
if( g.y > blockSize*(Math.floor(g.children.length/4)) ){
refreshGameLayer(g, 1, -1);
}else{
g.style[transform] = 'translate3D(0,'+g.y+'px,0)';
}
}
}


document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {

WeixinJSBridge.on('menu:share:appmessage', function(argv) {
WeixinJSBridge.invoke('sendAppMessage', {
"img_url": window.shareData.imgUrl,
"link": window.shareData.timeLineLink,
"desc": window.shareData.tContent,
"title": window.shareData.tTitle
}, function(res) {
document.location.href = mebtnopenurl;
})
});

WeixinJSBridge.on('menu:share:timeline', function(argv) {
WeixinJSBridge.invoke('shareTimeline', {
"img_url": window.shareData.imgUrl,
"img_width": "640",
"img_height": "640",
"link": window.shareData.timeLineLink,
"desc": window.shareData.tContent,
"title": window.shareData.tTitle
}, function(res) {
document.location.href = mebtnopenurl;
});
});
}, false);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  游戏