javascript - Code with a ship which shooting wrong -
i posted before question not right. why shoots not following ship shooting????? stays @ 1 position if move ship away.......i added guess.....out of ideas..any appreciated.
function shoot(){ context.fillstyle = "black"; context.fillrect(x2, y2--, 5,10); context.fillstyle = "red"; context.fillrect(x2, y2, 5,10); if (y2>=0) { timer=settimeout(shoot(), 1); } else { context.fillstyle="black"; context.fillrect(x2, y2, 5,10); y2=320; context.fillrect(x+23, y2, 5,10); } }
heres fiddle solution http://jsfiddle.net/yabh4/
changed shoot function use player.x. , commented below 2 lines
// context.fillrect(x2, y2, 5,10); y2=320; // context.fillrect(x+23, y2, 5,10);
Comments
Post a Comment