Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
524 views
in Technique[技术] by (71.8m points)

java - One image works fine and other one slow code so much

So I am doing small game in android studio - java. And I was using 400x400 .png image as a ship. It worked well.

Bitmap.createScaledBitmap(BitmapFactory.decodeResource(context.getResources(),R.drawable.playermove),(int)(length),(int)(height),false);

I am using drawBitmap to draw image on screen.

Now I want to use different ship. Only thing that I changed is that instead of this image I use another one that is 150x150 also .png and game becomes so laggy and sloopy. Length and Height are 1/10 size of the screen. I have 8 ship pictures with similair dimensions and every one make game sloppy. Any idea why those pictures make everything sloppy and first one doesn't?

question from:https://stackoverflow.com/questions/65916915/one-image-works-fine-and-other-one-slow-code-so-much

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You are doing that on the UI thread. You shouldn't!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...