function cGunsight1::onLevelLoaded(%this, %scenegraph) { $pGunsight1 = %this; //mount the sight onto player pGunsight1.mount(Player1Image, -2, 0, 8, 1, 1, 1, 1); //pGunsight1.mount(Player1Image, -2, 0, 0, 1, 1, 0, 0); //pGunsight.setEnabled(1); } function cGunsight1::onMouseDragged(%this, %modifier, %worldPosition, %clicks) { pGunsight1.moveTo(%worldPosition, 1500, true, false, true, 0); %X_away = pGunsight1.getPositionX() - Player1Image.getPositionX(); %Y_away = pGunsight1.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 pGunsight1::onTouchMove(%this, %event) { pGunsight1.moveTo(%event.point, 1500, true, false, true, 0); %X_away = pGunsight1.getPositionX() - Player1Image.getPositionX(); %Y_away = pGunsight1.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 cGunsight2::onLevelLoaded(%this, %scenegraph) { $pGunsight2 = %this; //mount the sight onto player pGunsight2.mount(Player2Image, -2, 0, 8, 1, 1, 1, 1); //pGunsight2.mount(Player2Image, -2, 0, 0, 1, 1, 0, 0); //pGunsight.setEnabled(1); } function cGunsight2::onMouseDragged(%this, %modifier, %worldPosition, %clicks) { pGunsight2.moveTo(%worldPosition, 1500, true, false, true, 0); %X_away = pGunsight2.getPositionX() - Player2Image.getPositionX(); %Y_away = pGunsight2.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 cGunsight2::onTouchMove(%this, %event) { pGunsight2.moveTo(%event.point, 1500, true, false, true, 0); %X_away = pGunsight2.getPositionX() - Player2Image.getPositionX(); %Y_away = pGunsight2.getPositionY() - Player2Image.getPositionY(); %gunrotation2 = (mAtan(%Y_away, %X_away) / 3.142) * 180; Player2Image.rotateTo((%gunrotation2 + 180), 200, true, false, true, 0); $temprotation2 = %gunrotation2+180; }