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

Report as inappropriate.

FlyingRabidUnicornPig
FlyingRabidUnicornPig presents ...

2013/9/2

Magnifying Glass

Just a random idea I got a couple hours ago, got it done faster than I thought I would.

Magnify the background with the magnifying glass (currently a square)

Have fun!

In the future:
- Different Shapes for magnifying glass
- More Images to magnify.

You may use this code in your scenarios. Credit me first.

3869 views / 11 in the last 7 days

Tags: mouse with-source reusable magnify greenfootimage

open in greenfoot
Your browser is ignoring the <APPLET> tag.
danpostdanpost

2013/9/2

Change your MouseActor class act method to this: public void act() { MouseInfo mouse = Greenfoot.getMouseInfo(); if (mouse == null) return; setLocation(mouse.getX(), mouse.getY()); updateImage(); }
danpostdanpost

2013/9/2

Also, instead of copying each pixel color from one image to the next, just use the GreenfootImage method 'drawImage'. For example you can change one of your MagnifyImage class 'magnifyImage' methods to: public static GreenfootImage magnifyImage(GreenfootImage img) { GreenfootImage image = new GreenfootImage(img.getWidth()/2, img.getHeight()/2); image.drawImage(img, -img.getWidth()/4, -img.getHeight()/4); image.scale(img.getWidth(), img.getHeight()); return image; } and similar for the other one.
danpostdanpost

2013/9/2

Finally, in your world class 'makeDefault' method, add the following condition for the statements in the following block: if (UserInfo.isStorageAvailable()) { GreenfootImage ui = new GreenfootImage(UserInfo.getMyInfo().getUserImage()); ui.scale(100,100); def2.drawImage(ui,getWidth()/2-50,getHeight()/2-50); }
SPowerSPower

2013/9/2

Good idea, but I agree with danpost: change some code, so it won't crash etc.
Thanks for the help danpost! I'll add that to this scenario pretty soon.
I knew that there was a problem with the mouse! I thought I had fixed that. Thanks again!
A new version of this scenario was uploaded on Mon Sep 02 14:01:32 UTC 2013 Now should work on the site, and some touch ups. Thanks to danpost!
joeschmoejoeschmoe

2013/10/14

This looks really cool and I looked at the source code but none of it makes sense to me... You didnt put any //explanations on anything. Any chance you could explain some of it?
Yah, I'll add some stuff, don't expect anything tonight, but I'll add some comments within the next few nights. And I'll see if I can get Actor images as well.
joeschmoejoeschmoe

2013/10/15

When ever :P

See all comments

Want to leave a comment? You must first log in.

Who likes this?

No votes yet.