0xfd3495 Posted May 1, 2022 Share Posted May 1, 2022 Hello, I'm new in game progremming. I was read better than as performance BitmapText instead of Normal font on PixiJS. That's way I prefered BitmapText. I couldn't found detail. both any google searching and that in api documentation for update text as BitmapText. My way solve that's like is; remove object, create object as updated with new text, object add to child. import { Application, Graphics, BitmapText } from 'pixi.js' import {GlowFilter} from '@pixi/filter-glow'; function emit(name:string, payload:any = true, ms=10) { setTimeout(function(){ gameEvents.dispatchEvent(new CustomEvent(name, { detail: payload })); }, ms); } const gameEvents = document.createElement('div'); // .... let playerCoord: BitmapText; app.loader.add('desyrel', 'desyrel.xml') .load(function(){ updateCoord(0, 0); emit("LOADED_DESYREL_BMAP_FONT"); }); function updateCoord(x=0, y=0) { app.stage.removeChild(playerCoord); playerCoord = new BitmapText(`X: ${x}, Y: ${y}`, { fontName: 'Desyrel', fontSize: 24, align: 'left' }); playerCoord.x = 10; playerCoord.y = 10; app.stage.addChild(playerCoord); } function movement(gameObjet: any, stateKeys: any, speed: number = 4) { // .... updateCoord(gameObjet.position.x, gameObjet.position.y); } // .... function playerGameLoop(){ movement(player, stateKeys); } gameEvents.addEventListener("LOADED_DESYREL_BMAP_FONT", function(){ app.ticker.add(playerGameLoop); }); Above code woking correctly. But I wanted to learn real game programming architecture with performance. Therefore I want to ask you. Thank you for interest. Good works. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.