I have a score on my canvas that changes when the user collects a star. I want to change the font on the score text to my custom font but the game crashes when I run it. The error I get is " java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference"
My question is does anybody know what I'm missing? I'm not too sure where I'm going wrong. Any help at all would be appreciated.
My code:
Paint scorePaint;
Typeface typeFace = Typeface.createFromAsset(getAssets(), "fonts/PressStart2P-Regular.ttf");
scorePaint.setTypeface(typeFace);
scorePaint = new Paint();
scorePaint.setColor(Color.WHITE);
scorePaint.setTextSize(70);
scorePaint.setTextAlign(Paint.Align.LEFT);
canvas.drawText("" + score, 0, 110, scorePaint);