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

Comments for Scrolling SuperWorld

Return to Scrolling SuperWorld

danpostdanpost

2015/3/12

@EduandErnst, I am not quite sure what you mean. Maybe you can start a discussion thread and link an image of what you trying to describe.
danpostdanpost

2015/3/13

@EduandErnst, after further thought, I have come to believe that what you are experiencing has to do with .png files supporting transparency and .jpg not. Try drawing the .png file onto the background image, after filling the background image with color white if needed, instead of just setting the image as the background image. As the backdrop of your world window, the background image should be completely opaque (you should not be able to see "through" or "beyond" it).
danpostdanpost

2015/3/13

@EduandErnst, when I said 'Try drawing ... " in the last comment, I meant as an experiment to see how it works -- not to change the way the scrolling engine sets the image. To set the image of the scrolling background, you could create a new GreenfootImage the size of the 'png', fill it with white and draw the 'png' onto it before setting it as the scrolling background image.
danpostdanpost

2015/3/13

@EduandErnst, when I said 'Try drawing ... " in the last comment, I meant as an experiment to see how it works -- not to change the way the scrolling engine sets the image. To set the image of the scrolling background, you could create a new GreenfootImage the size of the 'png', fill it with white and draw the 'png' onto it before setting it as the scrolling background image.
danpostdanpost

2015/3/13

@EduandErnst, when I said 'Try drawing ... " in the last comment, I meant as an experiment to see how it works -- not to change the way the scrolling engine sets the image. To set the image of the scrolling background, you could create a new GreenfootImage the size of the 'png', fill it with white and draw the 'png' onto it before setting it as the scrolling background image.
EduandErnstEduandErnst

2015/3/14

Yes it seams like it doesn't work with partially transparent .png files, when I fill it with background color it works fine, well I had to fill it anyways. Thanks for the great help. BTW your scenarios are great.
JackhammerJackhammer

2015/4/24

@ danpost, do you have an email address I can contact you by regarding a project?
noskillznoskillz

2015/11/17

Helly, can i contact you private? its very important
FriendlyKFriendlyK

2016/3/6

Thanks a lot Danpost! This really helps out my little project in school.
AreebRazaAreebRaza

2016/5/21

@danpost so far i have used your Scrolling SuperWorld scenario to make a platformer game and it has been working fine, but when i add the feature of shooting fireballs it shoots from the starting point of my character but in my other scenario without scrolling shooting works perfectly fine here is my shootRight class: import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class ShootRight here. * * @author (your name) * @version (a version number or a date) */ public class ShootRight extends ShootingManager { private int shootingSpeed = 8; public ShootRight(){ getImage().scale(20,20); } public void act() { // Add your action code here. fly(); killBadGuys(); turn(7); } public void fly(){ setLocation(getX() + shootingSpeed, getY()); } } and here's my shootLeft class: import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class ShootLeft here. * * @author (your name) * @version (a version number or a date) */ public class ShootLeft extends ShootingManager { /** * Act - do whatever the ShootLeft wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ private int shootingSpeed = 8; public ShootLeft(){ getImage().scale(20,20); } public void act() { // Add your action code here. fly(); killBadGuys(); turn(7); } public void fly(){ setLocation(getX() - shootingSpeed, getY()); } } here's the code i used in my player class: public void act(){ shooting(); } public void shooting(){ if(Greenfoot.isKeyDown("s") && shootingCounter <= 0 && direction ==1){ getWorld().addObject(new ShootRight(), getX(), getY()); shootingCounter = 70; } if(Greenfoot.isKeyDown("s") && shootingCounter <= 0 && direction ==-1){ getWorld().addObject(new ShootLeft(), getX(), getY()); shootingCounter = 70; } if(Greenfoot.isKeyDown("d") && shootingCounter <= 0 && direction ==1){ getWorld().addObject(new ElementRight(), getX(), getY()); shootingCounter = 70; } if(Greenfoot.isKeyDown("d") && shootingCounter <= 0 && direction ==-1){ getWorld().addObject(new ElementLeft(), getX(), getY()); shootingCounter = 70; } }
danpostdanpost

2016/5/21

@AreebRaza, please start a discussion thread on this and use code tags to display the code (see below the 'Post a reply' box for the link 'Posting code? Read this!'). In the meantime I will look over my SWorld class to re-familiarize myself with it. Oh, and usually, lag will occur with larger backgrounds and/or too many objects in the world.
danpostdanpost

2016/5/22

@AreebRaza, after reviewing, I find that all you need to do is change all occurrences of 'getWorld()' to '((SWorld)getWorld())'.
AreebRazaAreebRaza

2016/5/22

@danpost i tried your idea but it still does the same thing, shoot from the starting point of the Actor. but i did find a great scenario at http://www.greenfoot.org/scenarios/13053 and in his SWorld class he just had a little bit of changes than your SWorld, in your SWorld in the you had the methd [code] public int getUnivX(int worldX) { return (scrollingWidth-getWidth())/2+worldX+scrolledX; } [/code] all he did was change it to [code] public int getUnivX(int worldX) { worldX+scrolledX; } [/code] and it worked anyway i appreciate your reply
danpostdanpost

2016/5/22

@AreebRaza, in the 'getUnivX' and 'getUnivY' methods, the amounts returned do appear to be totally screwed up. I must of had a brain-fart the day I wrote them. Maybe I should just have a 'getScrolledX' and 'getScrolledY' methods and let the user determine what to do with the information they return (so the above could be ascertained with 'int x = getX()+getScrolledX();'). Those methods are not used within the SWorld class itself, so changing them wont hurt anything.
A new version of this scenario was uploaded on 2016-05-22 10:07:48 UTC Simplified troublesome methods ('getUnivX' and 'getUnivY' changed to 'getScrolledX' and 'getScrolledY').
A new version of this scenario was uploaded on 2016-05-22 15:13:38 UTC
TanonicTanonic

2016/6/13

Hey I would really appreciate your help, I'm making a jump and run game for school and when walking left and right the blocks I jump on just move with me, how can I make them static?
danpostdanpost

2016/6/13

@Tanonic, you should probably start a new discussion thread on this. Show the code you are using for placing the actors in the world and the movement code of your main actor.
errorfree@123errorfree@123

2018/3/30

this website is related to technical thing i can gather so much od information from here but i have some other issues which is related to QuickBooks billing system it is the very easy way to manage the account in our devices but if you face any problem with this QuickBooks kindly contact to this website https://quickbooksupports.co/
DeleriumzDeleriumz

2018/11/25

is it possible if you could contact me via email dan? to discuss some of ur games imp4ck420@gmail.com thanks
21solderichM21solderichM

2020/2/20

game is great but slow startup
Roshan123Roshan123

2020/5/12

Best game ever seen
A new version of this scenario was uploaded on 2020-10-31 10:29:48 UTC
Roshan123Roshan123

2020/11/28

How to write a complain to greenfoot administrators They banded me from sending replies in discussion
Roshan123Roshan123

2020/11/28

If u want to know why i m complaining then go through this link https://www.greenfoot.org/scenarios/189
Roshan123Roshan123

2020/11/28

*banned
Roshan123Roshan123

2020/11/28

Ok, I think their is no way of writing a letter to Greenfoot administrator So atleast tell me how can i print an arrow sign I m able to print the arrow in blue j terminal but not in greenfoot window
Roshan123Roshan123

2020/11/28

It always prints " ? "
danpostdanpost

2020/11/28

@Roshan123, need example. What code did you use that always prints " ? " ?
Roshan123Roshan123

2020/11/28

getBackground().drawImage(new GreenfootImage("arrow",20,null,null)500,500); I copied the arrow symbol frm blue j terminal
danpostdanpost

2020/11/28

@Roshan123, the arrow is an image -- not text. You are using the wrong GreenfootImage constructor. Try: GreenfootImage bg = getBackground(); GreenfootImage arrow = new GreenfootImage("arrow.gif"); bg.drawImage(arrow, 500, 500);
Roshan123Roshan123

2020/11/29

Hey Danpost plz help me They r not approving my last post It was said that the process of approving will be done within 24 hrs but its more then 32 hrs(actually i m scared a little bit) And i swear that i have only posted youtube link of Michael kolling Is their any way to get rid of it( i mean to write a letter or something else)
Roshan123Roshan123

2020/11/29

Plz reply it.....
Roshan123Roshan123

2020/11/29

Am i permanently banned????
Roshan123Roshan123

2020/11/29

And abt arrow.gif Its not a gif Will it work???
danpostdanpost

2020/11/29

@Roshan123, I am quite sure it is not permanent. Your account will probably be back in order by Monday. That is, I would wait until the weekend is over before really getting concerned.
danpostdanpost

2020/11/29

@Roshan123, if not gif, then what?
Roshan123Roshan123

2020/11/29

int hex = 8595;// for arrow char ch = (char) hex; System.out.println(ch); Procedure which i followed :- Copy the arrow frm terminal and paste it in greenfoot I don't know but i think its not a gif
danpostdanpost

2020/11/29

@Roshan123, okay -- it is a character glyph. I basically copy/pasted the code given and I get a arrow, pointing downward, in the terminal.
Roshan123Roshan123

2020/11/29

So will it work by writing GreenfootImage arrow = new GreenfootImage("⬆");
danpostdanpost

2020/11/29

@Roshann123, not with that. Just use: ((char)8595) like: System.out.println(""+((char)8595)+"");
Roshan123Roshan123

2020/11/29

I think it will show it in terminal which i don't want System.out.println(""+((char)8595)+""); I want arrow to be shown in the world getBackground().drawImage(new GreenfootImage(""+((char)8595)+"",20,null,null)500,500); Will it work ⬆⬆⬆
Roshan123Roshan123

2020/11/29

I copied the arrow frm blue j terminal and wanted to paste it in greenfoot to show it in world
danpostdanpost

2020/11/29

@Roshan, it will work: getBackground().drawImage(new GreenfootImage(""+((char)8595), 20, Color.BLACK, new Color(0, 0, 0, 0)), 500, 500);
SwaggyXiaoSwaggyXiao

2021/1/25

Hi, I am just interested in how did u make the background moving?
danpostdanpost

2021/1/25

@SwaggyXiao, please refer to my Scrolling Tutorial scenario on image scrolling (see main text and link at bottom on "Actor follow scrolling code"). The scenario is located at: https://www.greenfoot.org/scenarios/18226
SwaggyXiaoSwaggyXiao

2021/1/28

THANK YOU!
AnJoMortoAnJoMorto

2021/2/16

Good Morning, is there a way to add moving enemies when using an ImageScrollWorld like this one. I can't figure a code that lets the enemies move around and at the same time keep them in synch with the rest of the game moving with the player movements. Thank you for your time
danpostdanpost

2021/2/16

@AnJoMorto, are you not creating them with a true boolean? addObject(new Enemy(), x, y, true);
AnJoMortoAnJoMorto

2021/2/17

@danpost oh yes I see. I only had the base code of the ImageScrollWorld from your scrolling tutorial (https://www.greenfoot.org/scenarios/18226). I just added the methods to add a scrollable object, and it works now. Thank you very much!