Phaser World Issue 14
Phaser 3 is now called Lazer.
Follow development in the repo and Mailing List.
Here are some of the changes made this week:
Development of sfxr is finished
Tidied up the sfxr files lots. Refactored them to remove invalid variable names, moved more globals into the data object and sorted out the Generate main loop to get rid of hacky for-loop calls.
Added in the missing synths: BlipSelect, HitHurt and Random. All generating and sounding good. Need to test it with a seedable RNG, but am happy with the output.
New Geometry Objects are in
Split the math distance file up into 3 separate functions, now in math/distance.
Created geom/intersect and added CircleToCircle
and CircleToRectangle
to it.
Finished work on the Rectangle class and broke it down as with Circle. It's now a nice small compact plain object with a handful of tiny helper getters.
Also created lots of Rectangle support functions: Area, Ceil, CeilAll, CenterOn, Clone, ContainsRect, ContainsXY, Copy, FitInside, FitOutside, Floor, FloorAll, GetAspectRatio, GetCenter, GetSize, Inflate, MergePoints, MergeRect, MergeXY, Overlaps, Perimeter, Random, Scale, Translate and Union. Phew :)
Started creating Ava tests for all of the new Rectangle functions.
Finished the SFXR port. Dynamic audio effects are now generating and playing perfectly :) I've done all of the synth effects, all of the generators and the Web Audio implementation of it. So far I've ported over the pre-defined synths: Explosion, LaserShoot, PickUpCoin, PowerUp and PushSound.
Still need to do the rest of the synths and add the synth cache, but it works and plays just great.
How to handle the new Cache
I'm a bit stuck with regard to how the new Cache will work in Lazer. From a technical point of view it's trivial, but semantically it's harder to determine its place.
In Phaser there is one single cache. The cache is split-up by file type and there are lots of corresponding methods like 'addCanvas' and 'getJSON'. Everything is key (string) based. So you can't have 2 images with the key 'background' for example. The cache is global, shared by all States.
This doesn't feel like the right approach for Lazer, but I don't want to overcomplicate things either. I could allow for each State to have its own Cache, but then populating the cache is a pain if you want to share assets between multiple States.
I could have one 'global' Cache, and then each State could have its own local cache as well (although again the same problem arises). I guess then if you created a new Sprite that used the image key 'background' it could look in the State level cache first, then fall back to the global one.
Or I could just have one global cache, but you can choose to partition it however you want. So you could create a 'mainmenu' partition within the cache, and put files in there. So each cache entry has a partition, a key and a file type. Meaning you could have a partition called 'Level1' and an image called 'background' and a piece of music called 'background' too.
The difficulty comes when you have to select where in the cache to get an asset from. I guess Sprites and so-on could have a 'cache partition' argument, along with their key, i.e.:
game.add.sprite(x, y, cachePartition, cacheKey, frameName)
I did think maybe it could be bound to the key somehow, perhaps using a colon or a pipe?
game.add.sprite(x, y, 'Level1:background', frameName)
But that means parsing every single key for a : or a | first which maybe doesn't matter, but equally doesn't appeal much either.
Any other suggestions?!
Phaser 3 is now called Lazer.
Follow development in the repo and Mailing List.
Here are some of the changes made this week:
Development of sfxr is finished
Tidied up the sfxr files lots. Refactored them to remove invalid variable names, moved more globals into the data object and sorted out the Generate main loop to get rid of hacky for-loop calls.
Added in the missing synths: BlipSelect, HitHurt and Random. All generating and sounding good. Need to test it with a seedable RNG, but am happy with the output.
New Geometry Objects are in
Split the math distance file up into 3 separate functions, now in math/distance.
Created geom/intersect and added CircleToCircle
and CircleToRectangle
to it.
Finished work on the Rectangle class and broke it down as with Circle. It's now a nice small compact plain object with a handful of tiny helper getters.
Also created lots of Rectangle support functions: Area, Ceil, CeilAll, CenterOn, Clone, ContainsRect, ContainsXY, Copy, FitInside, FitOutside, Floor, FloorAll, GetAspectRatio, GetCenter, GetSize, Inflate, MergePoints, MergeRect, MergeXY, Overlaps, Perimeter, Random, Scale, Translate and Union. Phew :)
Started creating Ava tests for all of the new Rectangle functions.
Finished the SFXR port. Dynamic audio effects are now generating and playing perfectly :) I've done all of the synth effects, all of the generators and the Web Audio implementation of it. So far I've ported over the pre-defined synths: Explosion, LaserShoot, PickUpCoin, PowerUp and PushSound.
Still need to do the rest of the synths and add the synth cache, but it works and plays just great.
How to handle the new Cache
I'm a bit stuck with regard to how the new Cache will work in Lazer. From a technical point of view it's trivial, but semantically it's harder to determine its place.
In Phaser there is one single cache. The cache is split-up by file type and there are lots of corresponding methods like 'addCanvas' and 'getJSON'. Everything is key (string) based. So you can't have 2 images with the key 'background' for example. The cache is global, shared by all States.
This doesn't feel like the right approach for Lazer, but I don't want to overcomplicate things either. I could allow for each State to have its own Cache, but then populating the cache is a pain if you want to share assets between multiple States.
I could have one 'global' Cache, and then each State could have its own local cache as well (although again the same problem arises). I guess then if you created a new Sprite that used the image key 'background' it could look in the State level cache first, then fall back to the global one.
Or I could just have one global cache, but you can choose to partition it however you want. So you could create a 'mainmenu' partition within the cache, and put files in there. So each cache entry has a partition, a key and a file type. Meaning you could have a partition called 'Level1' and an image called 'background' and a piece of music called 'background' too.
The difficulty comes when you have to select where in the cache to get an asset from. I guess Sprites and so-on could have a 'cache partition' argument, along with their key, i.e.:
game.add.sprite(x, y, cachePartition, cacheKey, frameName)
I did think maybe it could be bound to the key somehow, perhaps using a colon or a pipe?
game.add.sprite(x, y, 'Level1:background', frameName)
But that means parsing every single key for a : or a | first which maybe doesn't matter, but equally doesn't appeal much either.
Any other suggestions?!