ayrin
1
Hi, i have made this script for a button, what am i missing since it isn’t fired.
var Startbutton = pc.createScript('startbutton');
// initialize code called once per entity
Startbutton.prototype.initialize = function() {
this.entity.element.on('mouseup', this.loadscene, this);
this.entity.element.on('touchend', this.loadscene, this);
};
// update code called every frame
Startbutton.prototype.loadscene = function() {
var ent=this.app.root.findByTag('start');
for(var t=0;t<ent.length;t++) {
ent[t].enabled=false;
}
var url = this.app.getSceneUrl("Select");
this.app.loadSceneHierarchy(url,function(err,entity) {
if (!err) {
this.app.loadSceneSettings(url, function (err) {
if (!err) {
// success
} else {
// error
}
});
} else {
}
}.bind(this));
};
Hi @ayrin,
Make sure “Use Input” is checked in the editor.
Also, if you are using the Button Component, try using:
this.entity.button.on('click', function() {
});
instead.
That way, you won’t need separate lines for clicks and touches, and it won’t fire events if you make the button inactive.
1 Like
ayrin
3
It works but how do i delete the html document?
Hi @ayrin,
What do you mean delete the html document?
ayrin
5
I mean i have a document.body and i want to remove it when scene change
Is this an HTML file you’ve added? Usually with HTML you add a certain element like a <div>
not second body element to your page.
You can’t really remove the default document.body since that will remove the whole page including the PlayCanvas canvas running.
ayrin
7
So how can i remove the div?
EDIT: nevermind already done
yaustar
8
You can remove children from the document body. I do something similar here with the chat window when it is destroyed https://playcanvas.com/project/764032/overview/tlkio-chat-integration
2 Likes
ayrin
9
Thanks to both of you, now it comes the difficult task to create a user database with characters…wish me luck lol
1 Like