zy-asrs-flow/src/pages/map/index.jsx | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
zy-asrs-flow/src/pages/map/player.js | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
zy-asrs-flow/src/pages/map/index.jsx
@@ -39,6 +39,8 @@ }; }); let player; const Map = () => { const { initialState, setInitialState } = useModel('@@initialState'); const { styles } = useStyles(); @@ -55,7 +57,7 @@ const [mapEditModel, setMapEditModel] = React.useState(false); React.useEffect(() => { const player = new Player(mapRef.current, styles.dark); player = new Player(mapRef.current, styles.dark); setApp(player.app); setMapContainer(player.mapContainer); Utils.syncApp(player.app); @@ -78,13 +80,16 @@ const height = contentRef.current.offsetHeight; app.renderer.resize(width, height); }, [app, mapContainer, windowSize]) React.useEffect(() => { if (!mapContainer) { return; } console.log(mapEditModel); if (mapEditModel) { player.showGridlines(); } else { player.hideGridlines(); } }, [mapEditModel]); const onDrop = (sprite, x, y) => { @@ -99,8 +104,8 @@ <Layout className={styles.layout}> <Header className={styles.header}> <Row style={{ height: '100%' }}> <Col span={8} style={{}}></Col> <Col span={16} style={{ backgroundColor: '#3C40C6', }}> <Col span={8} style={{ backgroundColor: '#3C40C6' }}></Col> <Col span={16} style={{ backgroundColor: '#3C40C6' }}> <Flex className={styles.flex} gap={'large'} justify={'flex-end'} align={'center'}> <Button onClick={() => setMapEditModel(!mapEditModel)} size={'large'}> {!mapEditModel zy-asrs-flow/src/pages/map/player.js
@@ -77,6 +77,7 @@ fontFamily: 'MicrosoftYaHei', fontWeight: 'bold', }); coordinatesText.name = 'xyStr' coordinatesText.position.set(10, 10); this.app.stage.addChild(coordinatesText); @@ -88,6 +89,44 @@ this.app.view.addEventListener('mousemove', mouseMoveInfoTextHandler); } showGridlines = () => { if (!this.gridLineContainer) { this.gridLineContainer = generatePixiContainer('gridLineContainer'); this.app.stage.addChild(this.gridLineContainer); } const inte = 30; const lineDefaultAlpha = .5;; const lineDefaultColor = 0x000000; for (let i = 0; i < this.app.view.width / inte; i++) { const graphics = new PIXI.Graphics(); graphics.lineStyle(.3, lineDefaultColor, lineDefaultAlpha); graphics.beginFill(lineDefaultColor); graphics.moveTo(i * inte, 0); graphics.lineTo(i * inte, this.app.view.height); graphics.endFill(); this.gridLineContainer.addChild(graphics); } for (let i = 0; i < this.app.view.height / inte; i++) { const graphics = new PIXI.Graphics(); graphics.lineStyle(.3, lineDefaultColor, lineDefaultAlpha); graphics.beginFill(lineDefaultColor); graphics.moveTo(0, i * inte); graphics.lineTo(this.app.view.width, i * inte); graphics.endFill(); this.gridLineContainer.addChild(graphics); } } hideGridlines = () => { if (this.gridLineContainer) { this.app.stage.removeChild(this.gridLineContainer); this.gridLineContainer = null; } } appTicker = () => { TWEEDLE.Group.shared.update(); }