hilo允许触发DOM事件, 打开事件机制

2018-11-27  本文已影响34人  大胡子111

在hilo中默认是不能触发dom事件的,也就是说不能进行点击,鼠标按下,抬起等操作,需要允许触发dom事件,打开事件机制。

import Hilo from 'Hilo';
export default class Stage extends Hilo.Stage {  
    constructor(props) {
        super(props);
        this.init(); 
        // enableDOMEvent 允许触发DOM事件, 即打开事件机制
        this.enableDOMEvent([
            Hilo.event.POINTER_START,
            Hilo.event.POINTER_MOVE,
            Hilo.event.POINTER_END,
            'click'
        ])
    }

    init() {
        new Hilo.Bitmap({    
            image: 'images/html1.png',  
            y: 100,   
            x: 100,  
            scaleX: 1,   
            scaleY: 1   
        }).addTo(this)
        .on(Hilo.event.POINTER_START, ()=>{  //上面已经打开了事件机制,可以使用事件了哦!
           console.log('打印111')
        })

        var ticker = new Hilo.Ticker(60);
        ticker.addTick(this);
        ticker.start();
    }
}
上一篇 下一篇

猜你喜欢

热点阅读