首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >React Pixi响应阶段

React Pixi响应阶段
EN

Stack Overflow用户
提问于 2020-01-09 20:25:37
回答 1查看 671关注 0票数 0

我正在尝试让我的阶段具有响应性,但是在使用react库时我不太确定如何做到这一点:

代码语言:javascript
复制
<Stage options={{backgroundColor: 0xffffff, radius: 1, width: 736, height: 414}}>

    <Sprite image="baseBike.png" x={100} y={100}/>

    <Sprite image={this.state.saddle.image} x={this.state.saddle.x} y={this.state.saddle.y}
            scale={{x: this.state.saddle.scale.x, y: this.state.saddle.scale.y}}/>


    <Sprite image={this.state.steering.image} x={this.state.steering.x}
            y={this.state.steering.y}
            scale={{x: this.state.steering.scale.x, y: this.state.steering.scale.y}}/>
    <Sprite image="circle.png" x={290} y={90} scale={{x: 1, y: 1}}
            interactive={true}
            pointerdown={() => {
                this.toogleMenu("saddle");
            }}
    />
    <Sprite image="circle.png" x={530} y={130} scale={{x: 1, y: 1}}
            interactive={true}
            pointerdown={() => {
                this.toogleMenu("steering");
            }}
    />

</Stage>

有人知道如何确保SpritesStage有响应吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-01-10 17:11:23

有很多方法可以实现这一点,但根据我的经验,当您的应用程序开始变得更大时,单独调整对象的大小将是一件非常痛苦的事情。

到目前为止,我发现的最简单和一致的方法是尽可能多地使用容器的概念。

你的舞台是一个容器。添加精灵或其他任何对象时,它们将相对于添加到的舞台进行定位和缩放。

尝试仅将任何比例和位置直接应用于舞台。看看下面的文章:https://webglfundamentals.org/webgl/lessons/webgl-resizing-the-canvas.html

它提供了一些仅用于调整画布大小的选项,这些选项也会影响画布的子对象。希望能有所帮助

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59663955

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档