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

这里写图片描述
项目描述 中秋节推广小游戏 规定时间吃月饼游戏
需求:增加订阅数
我的工作: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);
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值