如何从sks文件加载节点,然后应用在Scene Editor中定义的操作

时间:2018-03-03 12:05:58

标签: swift sprite-kit skspritenode skaction

我有两个sks文件,一个带有节点,另一个带有在Scene Editor中创建的动作。我想加载节点并将它们添加到另一个节点,然后对它们应用操作,如:

<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
require("PHPMailer.php");
require("Exception.php");
require("SMTP.php");
require('recaptcha-master/src/autoload.php');
        if ($_SERVER["REQUEST_METHOD"] == "POST") {
        // Get the form fields and remove whitespace.
        $name = strip_tags(trim($_POST["name"]));
                $name = str_replace(array("\r","\n"),array(" "," "),$name);
        $email = filter_var(trim($_POST["email"]), FILTER_SANITIZE_EMAIL);
        $tel = trim($_POST["tel"]);
        $message = trim($_POST["message"]);
        $recaptcha = $_POST["g-recaptcha-response"];
        $secret = '6LcjwkUUAAAAAENXcZtla40jNuPJGblZkYxLkXvf';
        }
    //$recaptcha = new \ReCaptcha\ReCaptcha($secret, new \ReCaptcha\RequestMethod\CurlPost());
    $recaptcha = new \ReCaptcha\ReCaptcha($secret, new \ReCaptcha\RequestMethod\SocketPost());
    $resp = $recaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);

    if ($resp->isSuccess()) {

        // Check that data was sent to the mailer.
        if ( empty($name) OR empty($message) OR empty($tel) OR empty($recaptcha) OR !filter_var($email, FILTER_VALIDATE_EMAIL)) {
            // Set a 400 (bad request) response code and exit.
            http_response_code(400);
            echo "Oops! There was a problem with your submission. Please complete the form and try again.";
            exit;
        }

        // Build the email content.
        $email_content = "Имя: $name\n";
        $email_content .= "Телефон: $tel\n";
        $email_content .= "Email: $email\n";
        $email_content .= "Сообщение: $message\n";

        // Send the email.

    $mail = new PHPMailer();
    //Server settings
        $mail->SMTPDebug = 0;                                 // Enable verbose debug output
        $mail->isSMTP();                                      // Set mailer to use SMTP
        $mail->Host = 'domain.tld';               // Specify main and backup SMTP servers
        $mail->SMTPAuth = true;                               // Enable SMTP authentication
        $mail->Username = 'info';                     // SMTP username
        $mail->Password = 'password';             // SMTP password
        $mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
        $mail->Port = 587;                                    // TCP port to connect to

    //Recipients
        $mail->setFrom('info@domain.tld', 'DOMAIN.TLD');
        $mail->addAddress('info@domain.tld', 'Information');  // Add a recipient
        $mail->addReplyTo('info@domain.tld', 'Information');

    //Content
        $mail->Subject = 'Новое сообщение с сайта DOMAIN.TLD' ;
        $mail->Body    = $email_content;

    $success = $mail->send();
        echo "success"; 

    } else {
        // Not a POST request, set a 403 (forbidden) response code.
        http_response_code(403);
        echo "Something went wrong. Please try again";
   }
?>

但是行动不适用于override func sceneDidLoad() { let heroScene = SKScene(fileNamed: "Hero") let head = heroScene?.childNode(withName: "HeroHead") as! SKSpriteNode let testAction = SKAction(named: "HeroTestAction") as! SKAction let loop = SKAction.repeatForever(testAction) let hero = SKSpriteNode(color: SKColor.white.withAlphaComponent(0) , size: CGSize(width: 50, height: 250)) let body = SKSpriteNode(color: SKColor.blue, size: CGSize(width: 50, height: 50)) head.removeFromParent() hero.addChild(head) hero.addChild(body) self.addChild(hero) head.run(loop) body.run(loop) } 。如果我将循环应用于headbody则可行。

我做错了什么?谢谢!

enter image description here

enter image description here

更新:当我第一次运行示例时,操作不起作用,但如果关闭应用程序并再次运行则可行。

enter image description here

1 个答案:

答案 0 :(得分:2)

我想说有一个有趣的“功能”,当你抓住像isPaused = true;

那样的参考精灵时

尝试添加此

head.isPaused = false;

我相信在从另一个场景中抓取一个精灵之前我遇到了类似的问题。