@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).
@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.
@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.
@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.
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.
@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;
}
}
@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.
@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
@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
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?
@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.
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/
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
@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);
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)
@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.
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
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 ⬆⬆⬆
@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
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
@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!
2015/3/13
2015/3/13
2015/3/13
2015/3/13
2015/3/14
2015/4/24
2015/11/17
2016/3/6
2016/5/21
2016/5/21
2016/5/22
2016/5/22
2016/5/22
2016/6/13
2016/6/13
2018/3/30
2018/11/25
2020/2/20
2020/5/12
2020/11/28
2020/11/28
2020/11/28
2020/11/28
2020/11/28
2020/11/28
2020/11/28
2020/11/28
2020/11/29
2020/11/29
2020/11/29
2020/11/29
2020/11/29
2020/11/29
2020/11/29
2020/11/29
2020/11/29
2020/11/29
2020/11/29
2020/11/29
2020/11/29
2021/1/25
2021/1/25
2021/1/28
2021/2/16
2021/2/16
2021/2/17
2023/8/1