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

Report as inappropriate.

danpost
danpost presents ...

2012/12/26

Light Beam Class Demo

A demonstration of a class that follows a 'light source' object that emits a beam of light. The 'Beam' class is fully documented with instructions on use (which is very easy). Includes methods to vary different aspects of the object.

Note: only one object of this class should be used at any time.

5288 views / 13 in the last 7 days

7 votes | 0 in the last 7 days

Tags: demo with-source class light danpost support support-class dark ambiance

This scenario is a member of: Support Classes by danpost


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

2013/4/24

Thanks for your help!
no problem
LaurenceLaurence

2016/9/5

Would it be possible for this to follow an actor and point in the direction of the cursor?
danpostdanpost

2016/9/5

@Laurence, if the actor points in the direction of the cursor, then the beam will also. The beam will always follow the "source" actor and point in the same direction that actor faces.
LaurenceLaurence

2016/9/5

public class Lamp extends Actor { int dir = 0; /** * Act - do whatever the Lamp wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { setRotation(90); } } I've made a simple 'lamp' image and indeed it turns 90 degrees but the beam stares straight forward weirdly enough.
danpostdanpost

2016/9/5

@Laurence, start a discussion thread on this. Show your complete world class and Lamp class codes and explain the problem and what the fix should do.
LaurenceLaurence

2016/9/5

Gotcha
A new version of this scenario was uploaded on 2016-12-07 05:02:42 UTC Some "collision" methods added.
A new version of this scenario was uploaded on 2016-12-07 05:03:07 UTC Some "collision" methods added.
A new version of this scenario was uploaded on 2020-10-30 20:04:05 UTC

See all comments

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

Who likes this?

JetLennit FlyingRabidUnicornPig birdy funkyflappy davemib123 miles7191 nooby123