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

2012/4/30

Variable Weights Help

1
2
3
danpost danpost

2012/5/9

#
I'm sorry, you do not even have to use that command as the constructor take a value for the maximum. The last parameter in the bar constructor call IS the maximum value. Create your bars as follows:
Bar pBar = new Bar("Projectile", "", 200, 400);
Bar cBar = new Bar("Counterweight", "", 2000, 4000);
addObject(pBar, x, y);
addObject(cBar, x2, y2);
Of course x, y, x2, and y2 values will have to be supplied.
danpost danpost

2012/5/9

#
As a side note (just to show how to change the value using 'setMaximumValue(int)'. The following would work:
Bar pBar = new Bar("Projectile", "", 50, 100);
pBar.setMaximumValue(400);
pBar.setValue(200);
Bar cBar = new Bar("Counterweight", "", 50, 100);
cBar.setMaximumValue(4000);
cBar.setValue(2000);
giving the same exact results as lines 1 and 2 above.
JMoller JMoller

2012/5/29

#
hey danpost, i hate to ask for help again, but how would i incorporated your bars with my projectile and counter weight class to change the mass of them?
danpost danpost

2012/5/29

#
Download my 'Barriers and Bars Demo' scenario, and check out how I sub-classed the Bar class to implement changing of the values by clicking with the mouse. You could probably use the exact same code as the 'MseActBar' sub-class of Bar. Also, make sure you create 'MseActBar' objects, instead of 'Bar' objects.
JMoller JMoller

2012/5/29

#
ok ill try that, thanks
JMoller JMoller

2012/5/29

#
so, my second question is how would incorporate this code with gravity to make the object fall since that not working either so i found out........
You need to login to post a reply.
1
2
3