The function f is defined as

f(x) = -2sinx ; -π≤x≤-π/2
= asinx + b ; -π/2<x<π/2
= cosx ; π/2≤x≤π
If f(x) is continuous in the interval -π≤x≤π fined the value of ‘a’ and ‘b’.

Since the f(x) is to be continuous, then end point of one piece must be the starting point of the second piece, etc.

So the link values are -π/2 and π/2
from y = -sinx, we get (-π/2, 2)
and from y = cosx, we get (π/2, 0)
so the middle function y = asinx + b must contain the points (-π/2,2) and (π/2,0)
2 = asin(-π/2) + b
2 = -a + b , #1

0 = asin(π/2) + b
0 = a + b , #2

add #1 and #2
2 = 2b
b = 1

back into #2
0 = a + 1
a = -1

so the second leg of the function is
y = -sinx + 1