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

2017/3/26

Set actor as having no image

Dylex Dylex

2017/3/26

#
Hi, i have actors in my scene that need to exist but do not need an image, when i set the image as unspecified i still see the default green foot image. How can i have absolutely no image shown by my actor?
danpost danpost

2017/3/26

#
Use:
setimage((GreenfootImage)null);
Out of curiosity, why do these actors need to exist in the world?
Dylex Dylex

2017/3/26

#
I have box colliders in my world that need to exist but not be seen.
danpost danpost

2017/3/26

#
Dylex wrote...
I have box colliders in my world that need to exist but not be seen.
Would they not need a size then? have transparent images instead of NO image?
Dylex Dylex

2017/3/27

#
danpost wrote...
Dylex wrote...
I have box colliders in my world that need to exist but not be seen.
Would they not need a size then? have transparent images instead of NO image?
That information is handled inside the BoxCollider class non graphically, but creating a real object in the world because it means greenfoot can organise them instead of me having to manually do that. The colliders work strictly when sides are aligned with the x & y axis, i work out the coordinate positions of each of the sides of the box and use that to make calculations:
        topY = (y - halfHeight) - parentY; // These have to be recalculated as the player moves the world around.
        bottomY = (y + halfHeight) - parentY;
        rightX = (x + halfWidth) - parentX; 
        leftX = (x - halfWidth) - parentX;
Doing things like this makes it much easier for me than using an image as i have to do calculations such as intersections of the edges of the boxes.
danpost danpost

2017/3/27

#
Dylex wrote...
That information is handled inside the BoxCollider class non graphically, but creating a real object in the world because it means greenfoot can organise them instead of me having to manually do that. The colliders work strictly when sides are aligned with the x & y axis, i work out the coordinate positions of each of the sides of the box and use that to make calculations < Code Omitted > Doing things like this makes it much easier for me than using an image as i have to do calculations such as intersections of the edges of the boxes.
I wonder if all that is really necessary as the Actor class has methods to check for collisions. What actions are you performing due to the results of these calculations? How are the boxes themselves influenced by these results?
Dylex Dylex

2017/3/28

#
danpost wrote...
Dylex wrote...
That information is handled inside the BoxCollider class non graphically, but creating a real object in the world because it means greenfoot can organise them instead of me having to manually do that. The colliders work strictly when sides are aligned with the x & y axis, i work out the coordinate positions of each of the sides of the box and use that to make calculations < Code Omitted > Doing things like this makes it much easier for me than using an image as i have to do calculations such as intersections of the edges of the boxes.
I wonder if all that is really necessary as the Actor class has methods to check for collisions. What actions are you performing due to the results of these calculations? How are the boxes themselves influenced by these results?
I dont trust greenfoot enough to do collision detection efficient as my game is quite large, the software is unreliable enough so i feel handling colliders is be better, although i'm sure my method could be faster. All the colliders do is detect if the player is inside them, but the whole system is flawed at the moment so it required a redesign, but i have no need to have pixel perfect collision like what the greenfoot engine checks against.
danpost danpost

2017/3/28

#
I do not think greenfoot does anything more than what you are trying to do. The 'touching' and' 'intersecting' methods are "box" collision methods in that they only detect intersections among the images (the rectangular image -- not the non-transparent sprite of the image).
Dylex Dylex

2017/3/28

#
I have other methods that require the exact coordinates of the lines at the boundaries of the box for line casting and stuff like that, might as well use them for collision detection. Additionally, i want it so that the colliders restrict the coordinates of the player, rather than stopping him from moving his own coordinates , which i thinking would be what would happen if i did use intersect() or anything like that. I need to be able to have more information that just whether the player touches another object.
You need to login to post a reply.