小编Dar*_*tar的帖子

由于缺少入口点,场景无法到达

我有一个游戏,如果你击中敌人,你去游戏画面.我在main.storyboard中添加了一个视图控制器,并创建了GameOver类.但是,它说我需要一个入口点,当我加载应用程序时,它只是一个空白屏幕.问题是,我真的不需要一个入口点,因为当敌人与玩家发生碰撞时,我会在代码中切换场景.不需要按钮"入口点".怎么解决这个问题?

在此输入图像描述

在此输入图像描述

这是与敌人发生碰撞的代码:

func CollisionWithEnemy(Enemy: SKShapeNode, Player: SKSpriteNode) {

    //Highscore
    var ScoreDefault = NSUserDefaults.standardUserDefaults()
    ScoreDefault.setValue(Score, forKey: "Score")
    ScoreDefault.synchronize()


    if (Score > Highscore) {
        var HighscoreDefault = NSUserDefaults.standardUserDefaults()
        HighscoreDefault.setValue(Score, forKey: "Highscore")
    }

    var gameOver:SKScene = GameOver(size: self.size)
    ScoreLabel.removeFromSuperview()
    Enemy.removeFromParent()
    Player.removeFromParent()
    self.view?.presentScene(gameOver, transition: transition)


}
Run Code Online (Sandbox Code Playgroud)

xcode ios sprite-kit swift

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

self.view?.presentScene:在解包一个Optional值时意外发现nil(Swift)

我试图切换场景但我的应用程序崩溃给我这个错误:

crash
crash
fatal error: unexpectedly found nil while unwrapping an Optional value
(lldb) 
Run Code Online (Sandbox Code Playgroud)

这是我切换场景的代码:

func switchscenes() {

    if display >= 2 {
        Player.removeFromParent()
        PlayerRight.removeFromParent()
        PlayerLeft.removeFromParent()
        fireHair.removeFromParent()
        fireHairRight.removeFromParent()
        fireHairLeft.removeFromParent()
        imageRightView.removeFromSuperview()
        imageLeftView.removeFromSuperview()
                                    println("crash")
        var gameplayScene:SKScene = GamePlay(size: self.size)
                                    println("crash")
        self.view?.presentScene(gameplayScene)
                                    println("crash")
        display = 0

    }
}
Run Code Online (Sandbox Code Playgroud)

然后在视图中加载:

timer5 = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: Selector("switchscenes"), userInfo: nil, repeats: true)
Run Code Online (Sandbox Code Playgroud)

这是打印崩溃两次,但不是第三次显​​示

self.view?.presentScene(gameplayScene) 
Run Code Online (Sandbox Code Playgroud)

是错误的原因.我怎样才能解决这个问题?

编辑:

GamePlay.swift代码:

import SpriteKit
import Foundation
import UIKit
import iAd

//Collisions
struct PhysicsCategory {
static let Enemy : UInt32 = …
Run Code Online (Sandbox Code Playgroud)

crash null ios swift

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

仅当项目不存在时如何将项目放入 dynamodb

我在 dynamodb 中有一个表,它只有一个分区键,并且只有当数据库中不存在具有相同分区键的另一个项目时,我才想将一个项目放入数据库中。

\n\n

我尝试使用 ConditionExpression attribute_not_exists 无济于事。

\n\n

问题是数据库中可能尚不存在某个项目,因此 attribute_not_exists 失败并显示\n无效的条件表达式:运算符或函数需要文档路径;运算符或函数:attribute_not_exists

\n\n

编辑:\n您能否发布您使用的完整条件表达式+表分区键的名称?\xe2\x80\x93

\n\n
Key: {\n  username: event.pathParameters.username\n},\nExpressionAttributeValues: {\n  ":username": event.pathParameters.username\n},\nItem: {\n    userId: event.requestContext.identity.cognitoIdentityId\n},\nConditionExpression: "attribute_not_exists(:username)"\n
Run Code Online (Sandbox Code Playgroud)\n

amazon-web-services nosql amazon-dynamodb

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

点击全屏图片库

在https://willhay.io/photography/上,我有一堆不同的图片.

我希望用户能够点击图像,然后进入一种全屏图像库,箭头来回切换图像和X按钮返回主摄影页面.

我的服务器上有完全分辨率的单独图像.

我是否只需将当前图像链接转到每个全屏/分辨率图像的页面?我觉得有一个更简单的方法来做到这一点.任何有关此事的帮助将不胜感激!

谢谢你的时间!

html css jquery image

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

在Google图表中使用Datetime作为X轴上的值

我在MySQL表中使用比特币价格数据和日期时间.由于一些奇怪的原因,它为每个x值设置相同的日期,并且y值是倾斜的并且看起来不合规定.最近的Y值应该是当前价格.这是我用来创建图表的代码:

function drawAxisTickColors() {
  var data = new google.visualization.DataTable();
  data.addColumn('number', 'Price');
  data.addColumn('datetime', 'Date');
  var dateArr2 = (<?php echo json_encode($dateArr); ?>).reverse();
    for (i = 0; i < dateArr2.length; i++) {
        dateArr2[i] = dateArr2[i].split(/[- :]/);
      }
  var bitcoinArr = (<?php echo json_encode($bitcoinPriceArr); ?>).reverse();
  console.log(bitcoinArr[0]);
  var length = Math.min(dateArr2.length, bitcoinArr.length);
  var rows = [];
  for (var i = 0; i < length; ++i) {
   rows.push([bitcoinArr[i], new Date(dateArr2[i])]);
  }
    data.addRows(rows);
Run Code Online (Sandbox Code Playgroud)

我认为图表上只使用了一个日期的原因与我在PHP中如何使用javascript数组dateArr2有关.

javascript php datetime google-visualization

2
推荐指数
1
解决办法
793
查看次数

使用 SKAction 调用一个函数每隔 X 秒 Swift

我有两个函数可以在 GamePlay 场景中生成敌人。我尝试使用 NSTimers 每 0.3 秒调用一次它们,但是当应用程序失去焦点时,计时器会继续运行并产生数百个敌人。

我读到 SKActions 会自动暂停,所以我尝试实现一个,但我收到一条错误消息:

无法使用类型为“(SKAction!)”的参数列表调用“repeatActionForever”

无法使用类型为“((), queue: (Double))”的参数列表调用“runBlock”

代码:

override func didMoveToView(view: SKView) {

superblockRandomizer = NSTimeInterval(arc4random_uniform(5) + 5)
runAction(SKAction.repeatActionForever(SKAction.sequence(SKAction.runBlock(spawnEnemies(), queue: (0.3)))))
runAction(SKAction.repeatActionForever(SKAction.sequence(SKAction.runBlock(spawnSuperBlocks(), queue: (superblockRandomizer)))))
}
Run Code Online (Sandbox Code Playgroud)

我想运行的两个函数是 spawnEnemies 和 spawnSuperBlocks。任何帮助将不胜感激!

编辑:当场景移动到视图时,它会立即生成超级块。这是我为超级块获得的代码

    let spawnSuperBlock = SKAction.sequence([SKAction.runBlock(spawnSuperBlocks), SKAction.waitForDuration(superblockRandomizer)])
    runAction(SKAction.repeatActionForever(spawnSuperBlock))
Run Code Online (Sandbox Code Playgroud)

它不应该在产卵前至少等待 superblockRandomizer 时间吗?

ios skaction swift

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

PHP的API请求加载速度较慢

我正在使用PHP从多个比特币交易所获取价格数据和交易量数据,但是当您加载页面时,它需要将近20秒。如何改善载入时间?我认为这与卷曲有关。

 <?php
    function getData($url) {
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    $rawData = curl_exec($curl);
    curl_close($curl);
    return json_decode($rawData, true);
    }
    //BTC Volume LocalBitcoins
    $BTCVolumeLocal = getData('https://localbitcoins.com/bitcoinaverage/ticker-all-currencies/');
    $LocalVolume = $BTCVolumeLocal["USD"]["volume_btc"];

    //BTC Volume BTCE
    $BTCVolumeBTCE = getData('https://btc-e.com/api/3/ticker/btc_usd');
    $BTCEVolume = $BTCVolumeBTCE["btc_usd"]["vol_cur"];

    //BTC Volume Bitstamp
    $BTCVolumeStamp = getData('https://www.bitstamp.net/api/ticker/');
    $StampVolume = $BTCVolumeStamp["volume"];

    //BTC Volume Bitfinex
    $BTCVolumeFinex = getData('https://api.bitfinex.com/v1/pubticker/btcusd');
    $FinexVolume = $BTCVolumeFinex["volume"];

    //BTC Volume OKCoin
    $BTCVolumeOK = getData('https://www.okcoin.com/api/ticker.do?ok=1');
    $OKCoinVolume = $BTCVolumeOK["ticker"]["vol"];

    //BTC Volume LakeBTC
    $BTCVolumeLake = getData('https://www.lakebtc.com/api_v1/ticker');
    $LakeVolume = $BTCVolumeLake["USD"]["volume"];

    //Totals the Volumes
    $TotalVolume …
Run Code Online (Sandbox Code Playgroud)

php api bitcoin

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