从 新人求助,触摸事件监听问题~ 继续讨论:
想要实现的功能:
第二次触摸会把第一次触摸时生成的NewNote销毁后再生成新的NewNote
但是现在完全不生成NewNote
代码如下
cc.Class({
extends: cc.Component,
properties: {
NewNotePrefab:{
default:null,
type:cc.Prefab
},
bar0:{
default:null,
type:cc.Node
},
bar1:{
default:null,
type:cc.Node
},
},
setNoteFunction:function(){
//把this.bar0给setNoteFunctionsub的targetbar
this.setNoteFunctionsub(this.bar0);
this.setNoteFunctionsub(this.bar1);
},
setNoteFunctionsub:function(targetbar){
targetbar.on("touchstart",function(){
cc.NewNote.destory();
var NewNote = cc.instantiate(this.NewNotePrefab);
NewNote.parent = targetbar;
NewNote.setPosition(0,0);
},this);
},
onLoad () {
cc.repeatForever(this.setNoteFunction());
},
start () {
},
});Musical Notation Translator.zip (710.8 KB)
demo已上传
完成进度30%左右
实现功能:五线谱音符翻译为简谱





