Technical stuff
So this weekend i worked on level generator for creating random levels but i stuck on some Phaser/webgl bugs/features.
First one scrolling scaled tiles crops part of them its probably some lack of some resizing camera cropping area but i didnt fond yet how to do it properly.
Second one was more complicated is general problem with webgl UI it just sucks and i needed to somehow use ordinary dom elements instead. So I have connected angular js to manage UI stuff from outside of Phaser and I have used some mediator pattern to pass data between those two frameworks. I have created MediatorService on Angular dependency injection container and connect Phaser state with angular controller. Tricky part was that I needed to use angular injector from already initialized dom element instead of global angular object. I didnt work out why that was the case yet.
var domElement = document.querySelector('[data-ng-app="ui"]');
var ui = angular.element(domElement);
var mediator = ui.injector().get('mediatorService');
/* in phaser state initialization */
mediatorService.state = this;
/* in angular controller */
mediatorService.state.setWhateverData(dataFromAngular);
In the end i have some hybrid application where i think i will use angular for whole UI and style it with css and phaser for drawing game tiles and managing sounds and keyboard input.
0 comments