Hello everyone. This is my First post and I am a real Android newbie.
But I have coded in various other platforms for 50+ years.
My device is a Samsung A5 but that is irrelevant.
I am working with a sample APP on Github called AccelerometerPlay that has 5 small white balls running around the screen with the level of your device. Very simple, I have it compiled and running nicely on my phone.
Here is my frustrating problem: I have searched for hours for a way to programmatically change the colours of the balls from white to other colours.
The balls begin as a PNG resource as below:
class ParticleSystem {
static final int NUM_PARTICLES = 6;
private Particle mBalls[] = new Particle[NUM_PARTICLES];
private Particle mBallX;
ParticleSystem() {
/*
* Initially our particles have no speed or acceleration
*/
for (int i = 0; i < mBalls.length; i++) {
mBalls = new Particle(getContext());
mBalls.setBackgroundResource(R.drawable.ball); <<<<< I want to change the colour about here.
mBalls.setLayerType(LAYER_TYPE_HARDWARE, null);
addView(mBalls, new ViewGroup.LayoutParams(mDstWidth, mDstHeight));
}
}
They are in an array of drawables in a Particle system.
BUT, I cannot find any method anywhere that will change their colours.
And, a couple of times I thought I did find one but could not find the IMPORT to bring it into the APP>
Does anyone have a clue where to look.
Many thanks.
Jim Calvert
But I have coded in various other platforms for 50+ years.
My device is a Samsung A5 but that is irrelevant.
I am working with a sample APP on Github called AccelerometerPlay that has 5 small white balls running around the screen with the level of your device. Very simple, I have it compiled and running nicely on my phone.
Here is my frustrating problem: I have searched for hours for a way to programmatically change the colours of the balls from white to other colours.
The balls begin as a PNG resource as below:
class ParticleSystem {
static final int NUM_PARTICLES = 6;
private Particle mBalls[] = new Particle[NUM_PARTICLES];
private Particle mBallX;
ParticleSystem() {
/*
* Initially our particles have no speed or acceleration
*/
for (int i = 0; i < mBalls.length; i++) {
mBalls = new Particle(getContext());
mBalls.setBackgroundResource(R.drawable.ball); <<<<< I want to change the colour about here.
mBalls.setLayerType(LAYER_TYPE_HARDWARE, null);
addView(mBalls, new ViewGroup.LayoutParams(mDstWidth, mDstHeight));
}
}
They are in an array of drawables in a Particle system.
BUT, I cannot find any method anywhere that will change their colours.
And, a couple of times I thought I did find one but could not find the IMPORT to bring it into the APP>
Does anyone have a clue where to look.
Many thanks.
Jim Calvert