This site requires JavaScript, please enable it in your browser!
Greenfoot back
AbdulrazaqAS
AbdulrazaqAS wrote ...

2022/7/6

Not displaying User Image

AbdulrazaqAS AbdulrazaqAS

2022/7/6

#
I want to make a profile page with some details and user image at the top. I don't know why the image is not showing. This is the code
private Board myInfoBoard = new Board();
GreenfootImage img = myInfoBoard.getImage();

if (UserInfo.isStorageAvailable()) {
                        UserInfo myInfo = UserInfo.getMyInfo();
                        int deactivations = myInfo.getInt(2);
                        int explosions =  myInfo.getInt(3);
                        int plays = myInfo.getInt(1);
                        int aborts = plays - (deactivations + explosions);
                        int bestTime = myInfo.getInt(4);
                        img.drawString(""+ deactivations + "x\n" + explosions + "x\n" + plays + "x\n" + aborts + "x\n" + bestTime + "s\n" + myInfo.getInt(5) + "s", img.getWidth()/2 - img.getWidth()/6, 210);
                        img.drawString("Name:\n" + myInfo.getUserName(), 5, 110);
                        img.setFont(new Font(20));
                        img.drawString("Lucky Trials: " + myInfo.getInt(7) + "x", 5, 70);
                        img.setFont(new Font(25));
                        
                        GreenfootImage myImg = myInfo.getUserImage();
                        myImg.scale(100, 100);
                        img.drawImage(myImg, 168, 3);
                    }
addObject(myInfoBoard, getWidth()/2, getHeight()/2);
The whole class is in my Bomb deactivation scenario, the FirstScreen Class (check inside checkClicks method). In the app, it shows the name of the player as the image, so it works in the app.
RcCookie RcCookie

2022/7/6

#
UserInfo.getUserImage is broken. It’s not your code.
AbdulrazaqAS AbdulrazaqAS

2022/7/8

#
RcCookie wrote...
UserInfo.getUserImage is broken. It’s not your code.
Ok, so what should I do?
RcCookie RcCookie

2022/7/12

#
Don’t show the image. It won’t work.
danpost danpost

2022/7/12

#
RcCookie wrote...
Don’t show the image. It won’t work.
Or, create your own images (like it does locally, which makes square gray boxes with the user names within them).
AbdulrazaqAS AbdulrazaqAS

2022/7/14

#
Ok, thank you all.
You need to login to post a reply.