1、创建一个函数名为 showFruit 的函数。 2、该函数可以传入一个参数,在函数内将该参数赋值给 val.text。 3、变量 a 为传入的水果字符串,调用 showFruit 函数并传入变量 a ,运行显示该水果名称。var app = new PIXI.Application(400,200); document.body.appendChild(app.view); var val = new PIXI.Text(""); val.style.fill = 0xffffff; val.x
时间: 2023-11-22 09:52:07 浏览: 72
Sure, here's the code you requested:
```
var app = new PIXI.Application(400, 200);
document.body.appendChild(app.view);
var val = new PIXI.Text("");
val.style.fill = 0xffffff;
val.x = 100;
val.y = 100;
app.stage.addChild(val);
function showFruit(fruit) {
val.text = fruit;
}
var a = "apple";
showFruit(a);
```
This code will create a PIXI application, add a text object to the stage, define a `showFruit` function that takes a fruit parameter and assigns it to the `val.text` property, set a variable `a` to "apple", and then call the `showFruit` function with `a` as the argument. The text object will display "apple" on the screen.
阅读全文