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

2021/6/15

I need help making a grabbing mechanic

1
2
eboy600 eboy600

2021/6/22

#
danpost wrote...
All in all, in hook class, using the following is easier:
if (isTouching(Bottle.class))
{
    removeTouching(Bottle.class);
    ((MyWorld)getWorld()).getCounter().bumpCounter(1);
}
(removing public static int score = 0; from MyWorld).
the only issue i have is that if there are mutiple bottles and they touch eachother one gets removed as if one is the hook
danpost danpost

2021/6/22

#
eboy600 wrote...
the only issue i have is that if there are mutiple bottles and they touch eachother one gets removed as if one is the hook
Show Bottle class codes.
eboy600 eboy600

2021/6/25

#
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) public class Bottle extends Actor { MyWorld thisGame; counter score; public void act() { move(2); { removeTouching(Bottle.class); //getWorld().addObject(Bottle.class); } if ( Greenfoot.getRandomNumber(10)<1) { turn (Greenfoot.getRandomNumber(90)-45); } if (isAtEdge()) { turn(180); } if (getY() < 360) setLocation(getX(), 360); } }
danpost danpost

2021/6/25

#
eboy600 wrote...
<< Code Omitted >>
Try this:
import greenfoot.*;

public class Bottle extends Actor
{
    public void act() 
    {
        move(2);
        if (Greenfoot.getRandomNumber(10)<1) turn (Greenfoot.getRandomNumber(91)-45);
        if (isAtEdge())  turn(180);
        if (getY() < 360) setLocation(getX(), 360);
    }   
}
eboy600 eboy600

2021/6/25

#
danpost wrote...
eboy600 wrote...
<< Code Omitted >>
Try this:
import greenfoot.*;

public class Bottle extends Actor
{
    public void act() 
    {
        move(2);
        if ( Greenfoot.getRandomNumber(10)<1) turn (Greenfoot.getRandomNumber(91)-45);
        if (isAtEdge())  turn(180);
        if (getY() < 360) setLocation(getX(), 360);
    }   
}
sorry dan post but i managed to ix the issue on my own much respect thanks for the help and wisdom
danpost danpost

2021/6/25

#
@epicfortnutgaming69, WARNING: this is a respectful site. Keep this up and YOU WILL get banned.
nccb nccb

2021/6/30

#
The problematic user's account has been disabled and their comments removed.
You need to login to post a reply.
1
2