function cGunsight1::onLevelLoaded(%this, %scenegraph) { $pGunsight1 = %this; //mount the sight onto player pGunsight1.mount(Player1Image, -2.0, 0, 0, 1, 1, 0, 0); //pGunsight.setEnabled(1); } function cICH::onMouseDragged(%this, %modifier, %worldPosition, %clicks) { pICH.moveTo(%worldPosition, 1500, true, false, true, 0); %X_away = pICH.getPositionX() - Player1Image.getPositionX(); %Y_away = pICH.getPositionY() - Player1Image.getPositionY(); %gunrotation = (mAtan(%Y_away, %X_away) / 3.142) * 180; Player1Image.rotateTo((%gunrotation + 180), 200, true, false, true, 0); $temprotation1 = %gunrotation + 180; } function cICH::onTouchMove(%this, %event) { pICH.moveTo(%event.point, 1500, true, false, true, 0); %X_away = pICH.getPositionX() - Player1Image.getPositionX(); %Y_away = pICH.getPositionY() - Player1Image.getPositionY(); %gunrotation = (mAtan(%Y_away, %X_away) / 3.142) * 180; Player1Image.rotateTo((%gunrotation + 180), 200, true, false, true, 0); $temprotation1 = %gunrotation + 180; } function Player1::onPositionTarget(%this) { pICH.setPosition(pGunsight1.getPositionX(), pGunsight1.getPositionY()); } function cGunsight2::onLevelLoaded(%this, %scenegraph) { $pGunsight2 = %this; //mount the sight onto player pGunsight2.mount(Player2Image, -2.0, 0, 0, 1, 1, 0, 0); //pGunsight.setEnabled(1); } function cICH2::onMouseDragged(%this, %modifier, %worldPosition, %clicks) { pICH2.moveTo(%worldPosition, 1500, true, false, true, 0); %X_away = pICH2.getPositionX() - Player2Image.getPositionX(); %Y_away = pICH2.getPositionY() - Player2Image.getPositionY(); %gunrotation2 = (mAtan(%Y_away, %X_away) / 3.142) * 180; Player2Image.rotateTo((%gunrotation2 + 180), 200, true, false, true, 0); $temprotation2 = %gunrotation2 + 180; } function cICH2::onTouchMove(%this, %event) { pICH2.moveTo(%event.point, 1500, true, false, true, 0); %X_away = pICH2.getPositionX() - Player2Image.getPositionX(); %Y_away = pICH2.getPositionY() - Player2Image.getPositionY(); %gunrotation2 = (mAtan(%Y_away, %X_away) / 3.142) * 180; Player2Image.rotateTo((%gunrotation2 + 180), 200, true, false, true, 0); $temprotation2 = %gunrotation2 + 180; } function Player2::onPositionTarget(%this) { pICH2.setPosition(pGunsight2.getPositionX(), pGunsight2.getPositionY()); }