GithubHelp home page GithubHelp logo

wasaxa / zgdanmaku Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zhgeaits/zgdanmaku

0.0 1.0 0.0 3.73 MB

android danmaku/danmu/tanmu implemented/renderered by opengl/opengles 2.0

License: Apache License 2.0

Java 99.20% Shell 0.80%

zgdanmaku's Introduction

ZGDanmaku

This is an android library which use opengles 2.0 to renderer danmaku effect.

初衷/Introduction

在Github上能找到很多开源的弹幕库,并且有很多是优秀的实现,基本上能够满足大众的需求,但是我却找不到使用opengles实现渲染的。于是我就自己着手学习一下opengles,并简单实现了一个弹幕。

效果/Demo

alt demo

Powering in YY:

alt yy

实现原理/Understanding Android OpenGLES

使用/Usage

  • 在xml布局中使用
<org.zhgeaits.zgdanmaku.view.ZGDanmakuView
        android:id="@+id/danmaku"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
  • 然后在java代码中使用
IZGDanmakuView danmakuView = (IZGDanmakuView) findViewById(R.id.danmaku);
danmakuView.setSpeed(100);//设置弹幕速度,单位px/s
danmakuView.setLines(24);//设置弹幕行数
danmakuView.setLeading(2);//设置行距

danmakuView.start();
  • 发送弹幕和控制
for (int i = 0; i < 1000; i ++) {
    danmakuView.shotTextDanmamku("hello world!");
}

Button closeSwitcher = (Button) findViewById(R.id.openOrClose);
closeSwitcher.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        if(danmakuView.isHide()) {
            danmakuView.show();
        } else {
            danmakuView.hide();
        }
    }
});

Button pauseSwitcher = (Button) findViewById(R.id.pauseOrResume);
pauseSwitcher.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        if(danmakuView.isPause()) {
            danmakuView.resume();
        } else {
            danmakuView.pause();
        }
    }
});

TODO

1.修改弹幕逻辑

2.修改为时间同步策略

Dependencies

1.由于glsurfaceview不能介于view的中间层,要么底层,要么顶层,是做不到处于中间层,然后透明的,所以需要使用TextureView。

GLTextureView:

2.使用了DanmakuFlameMaster的创建bitmap方法

License

Copyright (C) 2016 Zhang Ge <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

zgdanmaku's People

Contributors

zhgeaits 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.