Highlighted

Use hitTest in js

New Here ,
Apr 30, 2020

Copy link to clipboard

Copied

Hi,
I would like to detect the collision of two clips (b1 and v1) when clicking on a button (btvo). In js so that it works in html5. I tried with this code, but it doesn’t work you would have a solution? 

 

this.btvo.addEventListener("click", playClicked.bind(this));
function playClicked() {

var pt = v1.localToLocal(100,0,b1);
if (b1.hitTest(pt.x, pt.y)) { this.score.text = "OK"}

if (this.b1.hitTest(this.v1))

else {this.score.text = "No"}
}

 

Thank you

Views

95

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Use hitTest in js

New Here ,
Apr 30, 2020

Copy link to clipboard

Copied

Hi,
I would like to detect the collision of two clips (b1 and v1) when clicking on a button (btvo). In js so that it works in html5. I tried with this code, but it doesn’t work you would have a solution? 

 

this.btvo.addEventListener("click", playClicked.bind(this));
function playClicked() {

var pt = v1.localToLocal(100,0,b1);
if (b1.hitTest(pt.x, pt.y)) { this.score.text = "OK"}

if (this.b1.hitTest(this.v1))

else {this.score.text = "No"}
}

 

Thank you

Views

96

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Apr 30, 2020 0
Adobe Community Professional ,
May 03, 2020

Copy link to clipboard

Copied

try:

 

var pt = this.v1.localToLocal(100,0,this.b1);
if (this.b1.hitTest(pt.x, pt.y)) {

this.score.text = "OK";

} else {
this.score.text= "No";

}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 03, 2020 0
New Here ,
May 05, 2020

Copy link to clipboard

Copied

Thank you but it doesn’t work, if you have another idea...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 05, 2020 0
Adobe Community Professional ,
May 05, 2020

Copy link to clipboard

Copied

show the corrected code you tried

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 05, 2020 0
J-Yves LATEST
New Here ,
May 06, 2020

Copy link to clipboard

Copied

this.btvo.addEventListener("click", playClicked.bind(this));
function playClicked() {

var pt = this.v1.localToLocal (100,0, this.b1);
if (this.b1.hitTest (pt.x, pt.y)) {

this.score.text = "OK";

} else {
this.score.text = "Non";

}
}

Than you for your help.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 06, 2020 0