小编Krz*_*ski的帖子

如何调用另一个文件上找到的函数?

我最近开始学习C++和SFML库,我想知道我是否在一个名为"player.cpp"的文件上定义了一个Sprite,如何在位于"main.cpp"的主循环上调用它?

这是我的代码(请注意,这是SFML 2.0,而不是1.6!).

main.cpp中

#include "stdafx.h"
#include <SFML/Graphics.hpp>
#include "player.cpp"

int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "Skylords - Alpha v1");

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        window.draw();
        window.display();
    }

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

player.cpp

#include "stdafx.h"
#include <SFML/Graphics.hpp>

int playerSprite(){
    sf::Texture Texture;
    if(!Texture.loadFromFile("player.png")){
        return 1;
    }
    sf::Sprite Sprite;
    Sprite.setTexture(Texture);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

我需要帮助的main.cpp地方window.draw();在我的绘图代码中所说的位置.在该括号中,应该有我想要加载到屏幕上的Sprite的名称.据我搜索,并通过猜测尝试,我没有成功使绘图功能与我的精灵在另一个文件上工作.我觉得我错过了一些大的,非常明显的(在任何一个文件上),但是再一次,每个职业选手都曾经是一个新手.

c++ identifier sfml

60
推荐指数
2
解决办法
11万
查看次数

如何从通知中触发广播接收器

我想从通知中触发广播接收器.当我点击通知按钮时,它会显示以下错误:

"无法实例化接收器com.example.testservice.myBroad:java.lang.ClassCastException:com.example.testservice.myBroad无法强制转换为android.content.BroadcastReceiver"

*更新/编辑,现在正在工作* 1)嘿伙计们,请帮助处理从通知到广播接收器的2个按钮如何将通知广播触发器中的额外值传递给按下或暂停播放按钮的接收器?2)现在我的按钮工作,但当我点击通知文本时,它不会让我进入我的活动.任何帮助

我为2个按钮编写了这个代码,意图是额外的

 RemoteViews layout = new RemoteViews(getPackageName(), R.layout.notification);
            layout.setTextViewText(R.id.notification_title, getString(R.string.app_name));
            Intent clickIntent = new Intent();
            clickIntent.putExtra("button","pause");
            clickIntent.setAction(ACTION_DIALOG);

            PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), pendingRequestCode, clickIntent, pendingFlag);
            layout.setOnClickPendingIntent(R.id.notification_button,pendingIntent);
            builder.setContent(layout);


             layout = new RemoteViews(getPackageName(), R.layout.notification);
            layout.setTextViewText(R.id.notification_title, getString(R.string.app_name));
            Intent click = new Intent();
            clickIntent.putExtra("Button","play");
            clickIntent.setAction(ACTION_DIALOG);

            PendingIntent pi1 = PendingIntent.getBroadcast(getApplicationContext(), pendingRequestCode, click, pendingFlag);
            layout.setOnClickPendingIntent(R.id.notification_button1,pi1);
            builder.setContent(layout);
Run Code Online (Sandbox Code Playgroud)

myBroad接收器文件

Bundle extrasBundle = intent.getExtras();
    String str = (String) extrasBundle.get("button");       
    Toast.makeText(context, str, Toast.LENGTH_SHORT).show();

    context.stopService(new Intent(context, myPlayService.class));
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

void showNotification() {
     int pendingRequestCode = 0;
        int pendingFlag = …
Run Code Online (Sandbox Code Playgroud)

android android-intent android-layout

8
推荐指数
1
解决办法
7687
查看次数

Docker - 将 python 输出写入当前工作目录中的 csv 文件

我想学习如何使用 Docker 部署应用程序,我正在使用这个简单的 python 程序,该程序将一些数据写入当前工作目录中的 csv 文件。我可以在本地计算机的当前工作目录中看到 output.csv 文件,但是在运行 docker 映像时遇到问题。

在阅读了有关 stackoverflow 的各种文章和帖子后,使用“-v”挂载本地目录路径似乎是实现此目的的方法,但我无法获得正确的命令。我尝试在我的本地机器上创建一个名为“output_docker”的新目录(我还用此路径替换了程序中的 get.cwd() 选项)并将其与 -v 选项一起使用。

 docker container run -v "/Users/Desktop/output_docker" docker_image_name
Run Code Online (Sandbox Code Playgroud)

Python 代码 (scraper.py)

import pandas as pd
import os

data = [['tom', 10], ['nick', 15], ['juli', 14]]
df = pd.DataFrame(data, columns = ['Name', 'Age'])

dirpath = os.getcwd()
print("dirpath = ", dirpath, "\n")

output_path = os.path.join(dirpath,'output.csv')
print(output_path,"\n")

df.to_csv(output_path)
Run Code Online (Sandbox Code Playgroud)

文件

FROM python:3
ADD scraper.py /
RUN pip install pandas
CMD ["python3","./scraper.py"]
Run Code Online (Sandbox Code Playgroud)

本地机器上的输出

$python3 scraper.py
   Name  Age
0   tom …
Run Code Online (Sandbox Code Playgroud)

python-3.x docker dockerfile

6
推荐指数
1
解决办法
3535
查看次数

业力:Angular 4没有服务提供者

您好想在我的角度组件中测试真实的服务。但即时通讯低于错误。没有服务blservice的提供者

import {async, getTestBed,TestBed, inject } from '@angular/core/testing';

import { BlService } from './bl.service';
import { Injectable } from '@angular/core';
import { BaseRequestOptions, Http, Response, ResponseOptions, XHRBackend} from '@angular/http';

describe('BlService', () => {

  beforeEach(() => {TestBed.configureTestingModule({
    providers: [BlService]
   });
  });

  it('should be created', inject([BlService], (service: BlService) => {
    expect(service).toBeTruthy();
  }));
});
Run Code Online (Sandbox Code Playgroud)

错误:

错误:没有BlService的提供者!错误:没有BlService的提供者!
在ReflectiveInjector_.prototype._throwOrNull(HTTP://本地主机:9876 / _karma_webpack_ / vendor.bundle.js:42115:13
在ReflectiveInjector_.prototype._getByKeyDefault(HTTP://本地主机:9876 / _karma_webpack_ / vendor.bundle.js: 42154:13),
位于ReflectiveInjector_.prototype.get(http:// localhost:9876 / _karma_webpack_ / vendor.bundle.js:42086:13
上ReflectiveInjector_.prototype._getByKey(http:// localhost:9876 …

karma-runner angular

5
推荐指数
1
解决办法
7617
查看次数

Nexus Repository Manager - 删除旧的二进制资源

我想知道是否有办法从 nexus 存储库中删除许多项目。我有一些RAW类型存储库,其中包含一些 Web 应用程序版本(简单的 tar.bz2 二进制文件):

在此处输入图片说明

在一些存储库中有很多。我想释放一些磁盘空间。我可以删除单个文件:

在此处输入图片说明

但我没有看到批量删除选项。

对我来说最好的解决方案是自动或手动清理旧文件。免费版可以吗?如果是 - 如何?

Cleanup Policies在主菜单中没有看到:

在此处输入图片说明

Nexus Repository ManagerOSS 3.3.2-02

java artifacts nexus resource-cleanup nexus3

3
推荐指数
2
解决办法
7233
查看次数

如果我在PHP中使用第n个索引启动数组,它将占用多少内存?

我需要通过使用index作为第n个数字在Php中创建一个数组。例如:

<?php
    $A = array();
    $A['1000']='Some value';
Run Code Online (Sandbox Code Playgroud)

该数组是否会为剩余的999个索引占用内存?

php arrays

3
推荐指数
1
解决办法
69
查看次数