iOS spritekit does not display nodes

Asked 2 years ago, Updated 2 years ago, 64 views

Excuse me, let me ask you something rudimentary.
I'm currently trying to create a simple game, and I'm having trouble with the process.
Even if I write a program like the image, it doesn't appear on the simulator.
There are no errors and we are stuck.
How do I get it to show up?Or is there another problem?
I look forward to hearing from you.

import SpriteKit

classGameScene:SKScene{
    override func DidMoveToView (view:SKView) {

        //        create a sprite from an image
        let mySprite=SKSpriteNode(imageNamed: "kuri_2.png")
        //        Set Size in Size Properties
        mySprite.size = CGSize (width:20, height:20)
        //        Set in Position Properties
        // Specify the location of the image.
        mySprite.position=CGPoint(x:CGRectGetMidX(self.frame), y:CGRectGetMidY(self.frame));

        addChild (mySprite)

//        put in a rotational motion
        let action 1 = SKAction.rotateByAngle (CGFloat (90*M_PI/180), duration: 1)
//        add a moving motion
        let action 2 = SKAction.moveTo (CGPoint (x:400, y:400), duration:1)
//        Process two movements simultaneously
        let actionx = SKAction.group ([action1, action2])
//        I'm going to start moving.
        mySprite.runAction(actionx)

    }
    override functouchesBegan(touches:Set<UITouch>, withEvent:UIEvent?) {
           }

    override func update (currentTime:CFTimeInterval) {
        /* Called before each frame is rendered*/
    }
}

ios spritekit

2022-09-30 19:43

2 Answers

When I copied and pasted the code you provided into the Xcode project and built it, the node mySprite was displayed and I also animated it.Therefore, I think there is something wrong with the code other than the one you mentioned.


2022-09-30 19:43

How about Zposition?"Also, the possibility that gravity was working and it fell off the screen at the same time as the display, and it disappeared even before it could be seen, which is a rudimentary indication that I hope I can be of miraculous help."


2022-09-30 19:43

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.