Recently I have moved away from the Udacity course and tried to get back on track with the game development that I have wanted to do all along. I have returned my studies to Beginning Android Games, an Apress book I got a while back. When I first started trying to learn from this book I found the information to be far too heavy, I was not experienced enough with the Android OS to get it. Now that I have a better understanding, the pieces are coming together much easier.
While working through the examples, I have been playing around with the code and finding out the OTHER methods that some of the classes do. While I had made a game on Android following a "For Dummies" book in the past, this time I actually understand the process, the effect that the Activity Life Cycle has, and can see where the ideas I have fit into the code.
To help me keep notes and have an "in my own words" reference, I have been typing up notes into Google Keep, an app I have had on my phone for a long time and rarely used. Being able to type quickly has always prevented me from note-taking on my phone. I am a terrible touch screen typist! Using the in-browser version of Google Keep has been a lifesaver- actual keyboard typing, and sync to my phone for on the go note revision. I have found myself memorizing key concepts quicker with these notes, and can now comfortably say that an extremely basic framework in a regular View can flow pretty quickly from my fingers. I do enjoy making notes and even updating them to make them more precise, but I can't always be at my laptop- for this reason I have contemplated buying a bluetooth for a while. (I have planned to buy a tablet for myself for quite a while now and really wanted a keyboard for it- so I have been watching Amazon and Bestbuy for a deal daily!) I finally ordered myself a keyboard last night, and hopefully that gives me more opportunities to be productive- either in writing up ideas, taking notes or coding when I am not limited by the amount of time I can comfortably sit at the computer.
As an example of the notes I have been keeping, here is my first entry!
Soundpool is a RAM based storage for small soundFX files, ideally in .ogg format and shorter than about 5 seconds. Setting up a SoundPool requires the parameters indicating how many sounds can play simultaneously (20 is a good default), which sound stream is being used (AudioManager.STREAM_MUSIC for media of any type), and a final unused parameter, default 0.
SoundPool sp = new SoundPool(20, AudioManager.STREAM_MUSIC, 0);
The SoundPool default constructor has been deprecated with the release of Lollipop, and now utilises a Builder for instantiating a SoundPool object.
SoundPool sp = SoundPool.Builder()
.setUsage(audioAttributes)
.setStream()
.build();
To load a soundFX file to the Pool, you have to get an AssetFileDescriptor from the Asset file.
AssetManager assetManager = context.getAssets();
AssetFileDescriptor asset1 = assetManager.openFD("dir/filename.extension");
When adding the descriptor to the soundpool, it will return an integer which identifies the sound loaded, which can be used as a parameter later. It is vital therefore that any files loaded be done so in an integer expression. the load method itself will take in the AssetFileDescriptor and a sound priority int as parameters. The sound priority is currently unused as is default as 1 (similar I guess to the weight attribute in xml layouts, having them all at 1 gives uniform importance).
int asset1IdNum = sp.load(asset1, 1);
This asset can later be played using the SoundPool instance, by referencing the identifier for the resource, as well as some other parameters.
sp.play(identifierInt, float leftChannelVolume, float rightChannelVolume, int priority, int looping, float playbackSpeed)
The channelVolume parameters allow a sound to be set on one ear or the other. The priority again is unused and is defaulted to 0. Looping is often not a good idea for a sound effect and is thus set to 0, and playback speed will be 1 by default, less for slow play and more for fast playback.
When all use of the SoundPool is done, it is best practice to release the resources directly by using either specific calls to soundPool.unload(identifierInt) or to all resources using soundPool.release();
I have made notes on MusicStream, working with the View and onDraw() method (invalidating as a method of continuous graphics rendering), setting the application to keep the screen on, go fullscreen and hide the notification bar and working in SurfaceView and Threads.
I'm hoping that my notes will not only enable me to retain information better, but also that they may help me to guide others if they ask me for advice on starting on a similar path!
There are notes I have to include after todays coding to describe how to set a listener for loading files, as I wanted to have a specific sound effect play as my testing app opens (computer booting up sound effect from a monster catching game you may have heard of!)
Follow the learning and progress of a waiter who wants to make games. Java, Android and Game Development. Includes code snippets, book reviews and recommendations, game analysis and concept sketches!
Thursday, 27 August 2015
Friday, 21 August 2015
Update to R2-D2 print
Now with second layer for black. The registration I used worked out really well. The first attempt at a second layer that I did last time I was printing didn't line up well at all and I was super worried, luckily it worked out!
Subscribe to:
Posts (Atom)