javascript
1 const app2 = new PIXI.Application({ 2 width: 636, 3 height: 512, 4 view: document.getElementById('canvas2'), 5 resolution: window.devicePixelRatio || 1, 6 autoResize: true, 7 backgroundColor: 0x365a7c, 8 }); 9 const numOfParticles = 10; 10 const particleProperties = { 11 rotation: true, 12 position: true, 13 }; 14 const particleContainer = new PIXI.particles.ParticleContainer( numOfParticles, particleProperties ); 15 app2.stage.addChild( particleContainer ); 16 17 for ( var i = 0; i < numOfParticles; ++i ) { 18 const graphics = new PIXI.Graphics(); 19 graphics.lineStyle(0); 20 graphics.beginFill(0xDE3249, 1); 21 graphics.drawCircle(0, 0, 5); 22 graphics.endFill(); 23 graphics.x = Math.random() * ( app2.renderer.screen.width ); 24 graphics.y = Math.random() * ( app2.renderer.screen.height ); 25 particleContainer.addChild(graphics); //この行でエラーが出ます。 26 }
Uncaught TypeError: Cannot read property 'baseTexture' of undefined
というエラーが発生し、生成したgraphicsをtickerで操作したいのですがうまく動作しません。
particleContainer.addChild(graphics); この記述をコメントアウトするとエラーが消えたことは確認できたのですが、GraphicsをparticleContainerにaddChildする以外にどのような書き方があるのか、お教えいただければ幸いです。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/05/07 01:37