PDA

View Full Version : canon and bullet problem



rustyNails
December 19th, 2006, 08:52 PM
hi,
im trying to build a shooting game and i have a question.
how can i get the effect of bullet emerging from the canon?
i used to code it as bullet_.x = canon._x and bullet_.y = canon._y so the bullet starts from the middle of the canon. if the canon moves in the meantimes it looks a bit odd.
how can i make the bullet starts from the end of the canon, no matter where canon is at the moment???
reg,
rustyNails

Dhryn
December 19th, 2006, 09:27 PM
if you are only changing the x coords then you can use this.
taking the registry point on the canon to be the top left.
kepping the _y of the bullet the same.

bullet._x = canon._x+canon._width;

if the registry point of the canon is in the middle

bullet._x = canon._x+canon._width/2;


hope this helps

rustyNails
December 20th, 2006, 06:47 AM
thanks mate, i'll try this...

ajcates
January 4th, 2007, 01:13 AM
well best way to do it would be to make the cannon registration point at the place you want the bullet to come out. and just use



bullet_.x = canon._x
bullet_.y = canon._y

bombsledder
January 4th, 2007, 01:55 AM
bullet._x = canon._x
bullet._y = canon._y


you had a typo and you put the "." after the "_"