小编Bra*_*cus的帖子

将分数提交到Google Play游戏排行榜并显示新的排名

我正在研究一项游戏,其中分数被提交到活动中的排行榜,并且新的高分显示在片段中的排名.我有一些(有点)功能,但成功率约为10%.

流程如下:

方法handleLeaders

此方法获取每个排行榜的当前分数,如果新分数更好,则提交它并使用分数创建新的newHigh对象并将其添加到ArrayList.处理完所有3个排行榜后,调用方法setHighs.(在每个排行榜调用中检查错误)

public void handleLeaders(boolean win, int size, double t, final int toupees) {
    if(win) {
        final long time = (long) t;
        // Toupees
        Games.Leaderboards.loadCurrentPlayerLeaderboardScore(mGoogleApiClient,
                getString(R.string.leaderboard_trumps_toupeed),
                LeaderboardVariant.TIME_SPAN_ALL_TIME,
                LeaderboardVariant.COLLECTION_PUBLIC).setResultCallback(
                new ResultCallback<Leaderboards.LoadPlayerScoreResult>() {

                    @Override
                    public void onResult(Leaderboards.LoadPlayerScoreResult arg0) {
                        LeaderboardScore c = arg0.getScore();
                        int old;
                        if (c != null)
                            old = (int) c.getRawScore();
                        else
                            old = 0;
                        Games.Leaderboards.submitScore(mGoogleApiClient, getResources().getString(R.string.leaderboard_trumps_toupeed), old + toupees);

                        GameEndOverlay.newHighs.add(new newHigh("Trumps Toupee'd", old + toupees));

                        Status status = arg0.getStatus();
                        int statusCode = status.getStatusCode();

                        if (statusCode == GamesStatusCodes.STATUS_NETWORK_ERROR_NO_DATA) …
Run Code Online (Sandbox Code Playgroud)

java android google-play google-play-games

7
推荐指数
1
解决办法
720
查看次数

导航抽屉不显示但仍然打开

我正在使用Nutiteq SDK,它包含一个MapView,我也试图使用导航抽屉.我遇到的问题是,无论何时我从左侧滑动或单击图标打开抽屉都没有打开,但我无法移动地图,直到我向后滑动抽屉或再次单击图标.这让我相信抽屉是打开但没有显示.这是我的MainActivity.java和activity_main.xml:

MainActivity.java

public class MainActivity extends Activity {

 private MapView mapView;
 private LocationListener locationListener;
 private GeometryLayer locationLayer; 
 private Timer locationTimer;

 private String[] drawerListViewItems;
 private ListView drawerListView;
 private DrawerLayout drawerLayout;
 private ActionBarDrawerToggle actionBarDrawerToggle;

 @Override
 public void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     setContentView(R.layout.activity_main);

     setMap();

     // get list items from strings.xml
     drawerListViewItems = getResources().getStringArray(R.array.items);

     // get ListView defined in activity_main.xml
     drawerListView = (ListView) findViewById(R.id.left_drawer);

     // Set the adapter for the list view
     drawerListView.setAdapter(new ArrayAdapter<String>(this, 
                R.layout.drawer_listview_item, drawerListViewItems));

     // App Icon 
     drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); …
Run Code Online (Sandbox Code Playgroud)

java android nutiteq navigation-drawer

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

小写< - >大写函数不按计划工作

所以,我要做的是创建一个将大写字符切换为小写的函数,反之亦然.

这是我正在使用的:

#include <stdio.h>
#include <stdlib.h>

int caplowswitch(char string[], char switched[]);

int main(){

    char name[] = "whyisthisnotworking";
    char flipped[] = "";

    caplowswitch(name, flipped);


return 0;
}

int caplowswitch(char word[], char switched[]){

    char *ptrword = word;
    unsigned short int counter = 0;

    printf("Your text input is: %s \n", word);

    while(*ptrword != NULL){

    switched[counter] = (*ptrword ^ 0x20);
    counter++;
    ptrword++;

    }

    printf("Your flipped text is: %s \n", switched);

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

在学习的过程中.谢谢你的时间.

c bitmask

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

在while循环中扫描字符

char player_select(void){

    char player = 'n';

    while(player == 'n'){
        printf("Select your player (X or O): ");
        scanf("%c\n", &player);

        if(player != 'X' && player != 'O'){
            printf("Invalid input. Try again.\n");
            player = 'n';
        }
    }

printf("Your character input is: %c\n", player);
exit(0);
return player;
}
Run Code Online (Sandbox Code Playgroud)

我在这里得到一些奇怪的输出:

选择你的播放器(X或O):X

输入无效.再试一次.

选择你的播放器(X或O):i

你的角色输入是:X

c scanf char while-loop

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

添加效率我的ip blacklist-whitelist脚本

我的脚本打开两个文件:whitelist.txt和blacklist.txt填充ip地址.

我想在whitelist.txt中将blacklist.txt中所有ip的实例添加到变量中.

此脚本最多可以存储2个通配符.

它现在运行37分钟,我希望这更快.

$blacklist = file_get_contents("blacklist.txt");
$whitelist = file_get_contents("whitelist.txt");

$black_ips = explode("\n", $blacklist);
$white_ips = explode("\n", $whitelist);

$wildcard = array();
for($i = 0; $i < 256; $i++) {
  $wildcard[] = $i;
}

foreach($black_ips as $bkey => $black) {
  if(stristr($black, ".")) {

    foreach ($white_ips as $wkey => $white) {
      $count = substr_count($white, '*');

      if($count) {
        switch($count){
          case 1:
            foreach ($wildcard as $i) {
              if(substr($white, 0, strlen($white) - 1) . $i == $black){
                continue 4;
              }
            }
            break;
          case 2:
            foreach …
Run Code Online (Sandbox Code Playgroud)

php algorithm

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