Loading Image into Android Device
in
Android Processing
•
1 year ago
Hi, this problem has been bugging me for quite some time, tried various solution and doesnt work too. Heres the code below before i elaborate further.
===START OF CODE===
PImage img;
float sw, sh;
Snow snows[] = new Snow[1500];
void setup()
{
orientation(PORTRAIT);
sw = displayWidth;
sh = displayHeight;
img = loadImage("smallnightbg.jpg");
noStroke();
for(int i=0;i<snows.length;i++)
{
Snow s = new Snow(random(20), random((sw*(-1)),sw), random((sh*(-10)),0), random(10));
snows[i]=s;
}
}
void draw()
{
image(img,0,0);
fill(255);
for(int i=0;i<snows.length;i++)
{
Snow s = snows[i];
s.createSnow();
s.snowMove();
}
}
class Snow
{
float theta, x, y, snowSize;
Snow(float tempTheta, float tempX, float tempY, float tempSnowSize)
{
theta = tempTheta;
x = tempX;
y = tempY;
snowSize = tempSnowSize;
}
void createSnow()
{
float angleX = noise(theta)*(sw/3);
ellipse((x)+angleX,y,snowSize,snowSize);
}
void snowMove()
{
if(y < sh)
{
y += 2;
theta += 0.01;
}
}
}
===END OF CODE===
Apparently, this program is suppose to create snow "objects" and fall all the way down to the very bottom. Before this program fails to work, it was against a plain black background. So now i wanted to try it with a image as a background, i have match the size of the image against my android device which is a 480x800. Everything builds fine but it just couldnt run on my device, force closes whenever i attempted to run it. Help will be much appreciated, thanks!
1