Coder Social home page Coder Social logo

draw.js's Introduction

Draw.js

一个基于h5 canvas实现的简单游戏引擎。

demo

创建一个画布

    BGame.createWindow(0,0,1200,700,'1px solid #eee',document.getElementById('canvas'));
    BGame.init();

创建一个导演

    var director= new BDirector();
    director.init(BGame);

布置一个场景

    var scene =new BScene();

绘制一个精灵

    var rectSprite = new BSprite(100,100);

    rectSprite.draw = function () {
        this.transform();
        //画笔对象 
        this.Paint.fillRect(this.x(),this.y(),100,100);
    };
    //设置坐标中心点
    rectSprite.setCorePos(0.5);
    //设置位置 坐标系为右上角 0,0
    rectSprite.setPos({x:100,y:100});
    //设置scale属性
    rectSprite.setScale(0.5,0.5);

添加精灵到场景中

    scene.addChild(rectSprite)

导演开始工作

    director.run();

详细demo见源码。

欢迎大家进行交流。邮箱: [email protected]

draw.js's People

Contributors

jikangel avatar 348052148 avatar

Watchers

James Cloos avatar teen 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.