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

2021/2/5

Saving the world moves my objects randomly

theoo0308 theoo0308

2021/2/5

#
Hi!I am working on a project and there is a problem that makes it 10 times harder for me to creat in Greenfoot.After I add a new object in my world,after saving the world ,the applcation moves my objects randomly on the screen and keep them saved after being randomly moved.I checked the code and it seems like the app adds random SetLocation functions to my code after adding new objects in my world.Can you help me?
danpost danpost

2021/2/5

#
I do not know if anyone can help here, at least not with what was provided. I would suggest you copy current code (to provide here) add a new object (provide a detailed report of everything you do here), save the world and again copy the updated code (to provide here). Make sure that actors are randomly moved and not where you added them or moved them to last before saving. With a before and after and knowing exactly what you did, one might be able to deduce what might be going on.
theoo0308 theoo0308

2021/2/6

#
This is the code before adding additional objects
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
private void prepare()
{
 
        IepureJos iepureJos = new IepureJos();
        addObject(iepureJos,35,36);
 
        Cutie cutie = new Cutie();
        addObject(cutie,38,36);
        Cutie cutie2 = new Cutie();
        addObject(cutie2,32,36);
 
        Gard568 gard568 = new Gard568();
        addObject(gard568,41,35);
        Gard25 gard25 = new Gard25();
        addObject(gard25,41,37);
 
         
 
        Gard45 gard45 = new Gard45();
        addObject(gard45,45,35);
        Gard45 gard452 = new Gard45();
        addObject(gard452,47,35);
 
        Gard25 gard252 = new Gard25();
        addObject(gard252,47,36);
 
        Gard25 gard253 = new Gard25();
        addObject(gard253,47,37);
 
        Banut banut = new Banut();
        addObject(banut,49,36);
 
        
        
 
       
    }
And now this is the code after just adding some objects,without moving or doing anything to the ones already saved
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
private void prepare()
    {
 
        IepureJos iepureJos = new IepureJos();
        addObject(iepureJos,35,36);
 
        Cutie cutie = new Cutie();
        addObject(cutie,38,36);
        Cutie cutie2 = new Cutie();
        addObject(cutie2,32,36);
 
        Gard568 gard568 = new Gard568();
        addObject(gard568,41,35);
        Gard25 gard25 = new Gard25();
        addObject(gard25,41,37);
 
 
        Gard45 gard45 = new Gard45();
        addObject(gard45,45,35);
        Gard45 gard452 = new Gard45();
        addObject(gard452,47,35);
 
        Gard25 gard252 = new Gard25();
        addObject(gard252,47,36);
 
        Gard25 gard253 = new Gard25();
        addObject(gard253,47,37);
 
        Banut banut = new Banut();
        addObject(banut,49,36);
 
        
       
        banut.setLocation(51,35);
        Gard568 gard5682 = new Gard568();
        addObject(gard5682,51,35);
        Gard45 gard453 = new Gard45();
        addObject(gard453,55,35);
        Gard45 gard454 = new Gard45();
        addObject(gard454,57,35);
        Gard45 gard455 = new Gard45();
        addObject(gard455,59,35);
    }
As you can see,greenfoot moved my "banut"object but all I did was adding some objects.This happens everytime i add or move objects.When i save the world some random objects change their location
danpost danpost

2021/2/6

#
Interresting (and odd). Seems to have moved it to the exact location you placed the first new object at. I guess you just need to delete the first line anytime you Save the Wold (again). Either that, or try downloading greenfoot again. If that doesn't work, try an older version.
theoo0308 theoo0308

2021/2/6

#
Thanks for your suggestion. The version that does not have this problem is greenfoot 3.1.0 ,for everyone interested in this topic.
danpost danpost

2021/2/6

#
theoo0308 wrote...
Thanks for your suggestion. The version that does not have this problem is greenfoot 3.1.0 ,for everyone interested in this topic.
That is the exact one I am using (USB version). Have not tried newer.
You need to login to post a reply.