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

Report as inappropriate.

danpost
danpost presents ...

2013/12/9

Use of 'this' demo

The Portal class contain the most useful demonstration of using the 'this' keyword. Look closely as to how the constructor and the 'setPortal' method within that class work together.

It also demonstrate another way to create linked portals within the same and within different worlds.

2666 views / 7 in the last 7 days

3 votes | 0 in the last 7 days

Tags: demo with-source danpost portal this keyword

This scenario is a member of: Demos by danpost


open in greenfoot
Your browser does not support the canvas tag.
A new version of this scenario was uploaded on Mon Dec 09 00:24:33 UTC 2013 This is a demonstration of the uses of 'this' within your code.
A new version of this scenario was uploaded on Mon Dec 09 01:56:52 UTC 2013 This is a demonstration of the uses of 'this' within your code. Added some documentation.
A new version of this scenario was uploaded on 2020-10-29 18:01:04 UTC
OlexandraOlexandra

2021/4/24

Wow! I don't find where is the switch to another portal is made? Why getActor() works on a new port?
danpostdanpost

2021/4/25

@Olexandra, the "getActor" method may probably be better named as "takeActor" as that is what its partner portal is asking it to do. The link is made when the second constructor (the one with its partner portal passed to it) is used.
OlexandraOlexandra

2021/4/26

Thanks for the answer. It seems I've done the same, but only one port is working. The other keeps the actor and doesn't let it move. It depends on which Port I create first. Maybe you know what might be the problem? https://www.greenfoot.org/scenarios/27113 There is an exception on the site, but it works on my machine. I guess that's because of the images I upload to the program.
danpostdanpost

2021/4/26

@Olexandra, please start a new discussion thread on this issue.
OlexandraOlexandra

2021/4/26

@danpost created: https://www.greenfoot.org/topics/64323/0#post_143893

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

Who likes this?

kimber_jo Super_Hippo JetLennit