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

2023/4/12

How can i invert this code

Hhe Hhe

2023/4/12

#
Im making a game where you slide around and need to be stopped by sertain objects. I used this line of code but it made it so i can only walk through this type of object. how can i change it so i can not walk through "VastObject"? if ("up".equals(key)) { if (getOneObjectAtOffset(0,-1,VastObject.class) != null) setLocation(x,y-1); }
danpost danpost

2023/4/12

#
Hhe wrote...
Im making a game where you slide around and need to be stopped by sertain objects. I used this line of code but it made it so i can only walk through this type of object. how can i change it so i can not walk through "VastObject"? << Code Omitted >>
I think your logic if off. I would think the actor would move if there was NO VastObject instance found at the offset (use '== null').
Hhe Hhe

2023/4/12

#
OMG youre right
You need to login to post a reply.