Wie verwenden Sie das Schlüsselwort „dieses“ ProccesingJS?JavaScript

Javascript-Forum
Anonymous
 Wie verwenden Sie das Schlüsselwort „dieses“ ProccesingJS?

Post by Anonymous »

Mein Ziel ist es, einen Fähigkeitsbaum zu erstellen, der jeweils einen Abschnitt anzeigt. Wenn Sie auf einen klicken, gelangen Sie zum nächsten Zweig.
Hier ist mein Code:

Code: Select all

//var[
var branchLocation = function() {
this.x=0;
this.y=0;
this.rad=0;
this.diam=0;
this.r1=0;
this.g1=0;
this.b1=0;
this.r2=0;
this.g2=0;
this.b2=0;
};
var textWidthValue;
var circleDiameter;
var circleRadius;
var circleX;
var circleY;
//]
function branch(text1, x1, y1,r1,g1,b1,r2,g2,b2) {
//vars[
var textWidthValue = textWidth(text1);
var circleDiameter = max(50, textWidthValue + 40);
var circleRadius = circleDiameter / 2;
var circleX = x1;
var circleY = (3 / 5) * height - circleRadius;
branchLocation.push(branchLocation.x=x1);
branchLocation.push(branchLocation.y=y1);
branchLocation.push(branchLocation.diam=circleDiameter);
branchLocation.push(branchLocation.rad=circleRadius);
branchLocation.push(branchLocation.r1=r1);
branchLocation.push(branchLocation.g1=g1);
branchLocation.push(branchLocation.b1=b1);
branchLocation.push(branchLocation.r2=r2);
branchLocation.push(branchLocation.g2=g2);
branchLocation.push(branchLocation.b2=b2);
//]

line(x1, y1, x1, circleY);
fill(r1, g1, b1);
ellipse(circleX, circleY, circleDiameter, circleDiameter);

fill(r2, g2, b2);
textAlign(CENTER, CENTER);
text(text1, circleX, circleY);
}//to use bob put the text,rgb code of the circle, and rgb code of the text
fill(201, 50, 198);
// doesn't do anything. it is for rgb codes for calls of branch

branch("wild horses are beautiful", 184, 659,201, 50, 198,0);
branch("", 455, 630,18, 13, 179);

mouseClicked = function() {
if (mouseX>x-branchLocation.rad()){}// here is my error
};
Mein Fehler ist:
Wollten Sie rot statt rad eingeben? Falls Sie es vergessen haben, können Sie es wie red(color) | verwenden ProcessingJS
Können Sie helfen?
Mein Code in der Khan Academy ist auf dieser Webseite

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post