我正在统一制作游戏,玩家是立方体,每次碰撞时都会跳跃。
@Injectable()
export class HttpListener implements HttpInterceptor {
countRequest: number = 0;
countResponse: number = 0;
logEnable: boolean = environment.logEnable;
logUrl: string = environment.logUrl;
constructor(
@Inject( LoaderService ) public loaderService: LoaderService,
@Inject( Router ) public router: Router) {
}
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
this.loaderService.show();
this.countRequest++;
return next.handle(req).pipe(
map(event => {
if (event instanceof HttpResponse) {
if (this.logEnable) {
// log data
}
}
return event;
}),
catchError(error => {
if (this.logEnable) {
// log data
}
switch(error.status) {
case 400: {
break;
}
// not authorized
case 401: {
this.router.navigate(["/"]);
break;
}
case 404: {
// my specific 404 case
if (!this.router.url.includes("/test/create")) {
}
else {
// I want to return the error to my service.
}
}
}
return Observable.throw(error);
}),
finalize(() => {
this.countResponse++;
if (this.countRequest == this.countResponse) {
this.loaderService.hide();
this.countRequest = 0;
this.countResponse = 0;
}
})
)
}
}
我制作了一个可以随着动画上下移动的平台,但是当我的玩家跳上该平台时,力量得到了增强,并且比预期的要高。有什么解决办法吗?预先感谢。