Giter Site home page Giter Site logo

wxsubcontext's Introduction

微信原生排行榜

与cocos creator一起使用,体积小,使用简单易扩展


用法

  1. 将文件复制到微信子域目录
  2. Creator需要显示子域的节点添加WXSubContextView组件,子域的内容会适配到节点的大小。
  3. 微信开发者工具打开工程目录查看效果

方法

setPosition、 setContentSize、 setAnchorPoint、 setScale、 setRotation、 getBoundingBox、 removeAllChildren、 add、 destory

  1. cc.Sprite(path, isScale9) 创建精灵
  2. cc.Label(txt, size, color) 创建文本
  3. cc.ListView(size, def) 创建滚动视图

扩展

node.addEvent({
onTouchBegan:()=>{},
onTouchMove:()=>{},
onTouchEnded:()=>{},
onTouchCancel:()=>{}
})

实例-排行榜

rank

    创建listview
    var list = cc.ListView(cc.size(canvas.width, canvas.height - 20), {
        itemMargin: 4 //指定边距
    }
    创建列表项背景,设置九宫格为true
    var item = cc.Sprite(`${imgPath}item_bg.png`, true)
    ////////////////添加子节点
    //创建昵称
    var nick = cc.Label(nickname, 24, cc.c3b(145, 102, 70))
    //设置位置,锚点等
    nick.setPosition(..)
    nick.setAnchorPoint(...)
    //创建头像
    var avatar = cc.Sprite(avatarUrl)
    //添加到父节点
    item.add(nick)
    item.add(avatar)
    //将list添加到场景
    scene.add(list)  

rank

wxsubcontext's People

Contributors

zx6733090 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.