Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

236
Views
Clickable link from text on canvas in JavaScript

I have a video game made in JavaScript using the createjs library.

In the credits, I draw a URL on the canvas as text, but I wish to make it a clickable link.

I wish to make the above two links clickable.

After a lot of Googling and searching through forums I haven't found a similar question being asked.

I tried using the String link() method, but it does not work. The game launches but the credits won't open.

    var oLink = new createjs.Text("www.amzd.hr"," 20px "+FONT_GAME, "#000080");
    oLink.y = +270;
    oLink.textAlign = "center";
    oLink.textBaseline = "middle";
    oLink.x = +100;
    oLink.lineWidth = 300;
    let oLink = oLink.link("https://www.amzd.hr");
    _oPanelContainer.addChild(oLink);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can add an event listener to the Text instance that opens your link.

oLink.addEventListener("click", function(e) {
    window.open("https://url");
});

One note is that hit areas on text are pixel perfect, so you will want to add a hitArea. Here is some pseudo-code using getBounds() to determine the text size.

var b = oLink.getBounds();
oLink.hitArea = new createsjs.Shape(
    new createjs.Graphics().drawRect(b.x, b.y, b.width, b.height)
));

There is a tutorial on mouse interaction here: https://createjs.com/tutorials/Mouse%20Interaction/

Cheers,

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!