logo
down
shadow

SpriteKit - Preloader using GCD


SpriteKit - Preloader using GCD

By : user269580
Date : November 22 2020, 10:48 AM
I hope this helps . I don't do any progress bars since my levels take about a second to load. I have a seamless transition between levels. Before I was doing things this way my game would freeze for a moment in a transition because it had to load all the resources on the same thread that my game was running
I create a static method in my class to preload resources.
code :
// config is a struct with many parameters
class func createResources(config: HyperSceneConfig, withCompletion: (scene: HyperScene) -> ()){

    // load resources on other thread
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), {

        let hyperScene = HyperScene(config: config)

        // callback on main thread
        dispatch_async(dispatch_get_main_queue(), {
            // Call the completion handler back on the main queue.
            withCompletion(scene: hyperScene)
        });
    })

}
init(config: HyperSceneConfig) {


    super.init(size: config.size, viewController: config.viewController)

    self.backgroundColor = SKColor.blackColor()

    self.levelTime = 200

    // this is where i do all my setup before the scene is presented
    self.setupScene()
}
HyperScene.createResources(hyperConfig, withCompletion: {
    scene in
    self.scene = scene
    self.scene.scaleMode = .AspectFill
    self.skView.presentScene(self.scene)
    self.view.addSubview(self.skView)
})


Share : facebook icon twitter icon
Preloader question, preloader not on top of the page

Preloader question, preloader not on top of the page


By : Vikrant Rai
Date : March 29 2020, 07:55 AM
I wish this help you Why not use something existing like this: http://extensions.joomla.org/extensions/photos-a-images/images-slideshow/9868?
Preloader in as3 using preloader sample provided in cs5

Preloader in as3 using preloader sample provided in cs5


By : jfrederickson
Date : March 29 2020, 07:55 AM
I wish did fix the issue. Assets which have not linkage load until the frame they first appear, so if you move all your assets to the second (or later) frame, you could have code in the first frame that executes before all the other assets (in frame two or later) finish loading.
I want to show preloader for non ajax call and hide preloader after resources loaded?

I want to show preloader for non ajax call and hide preloader after resources loaded?


By : Tasha Alfano
Date : March 29 2020, 07:55 AM
it helps some times
How do I know last resource loaded for a web page request so that I can hide the preloader?
Spritekit Game Fails to build on Xcode 6.3 Cannot load module 'SpriteKit' as 'Spritekit'

Spritekit Game Fails to build on Xcode 6.3 Cannot load module 'SpriteKit' as 'Spritekit'


By : Nestor Ponce Valenti
Date : March 29 2020, 07:55 AM
This might help you I'm trying to build a SpriteKit Game and it fails with error: "Cannot load module 'SpriteKit' as 'Spritekit'" , SpriteKit with an uppercase K should do it.
how can i change my spritekit on collision in spritekit swift

how can i change my spritekit on collision in spritekit swift


By : Eky Ahamed Emon
Date : March 29 2020, 07:55 AM
wish help you to fix your issue If you want to change the Image of the Sprite, then you should use SKPhysicsContactDelegate Method.
In General that means that you have to implement the SKPhysicsContactDelegate, Make a new Struct:
code :
struct PhysicCategories {
        static let NoneC : UInt32 = 0x1 << 0
        static let Bird : UInt32 = 0x1 << 1
        static let PlatformC : UInt32 = 0x1 << 2
        static let FinishC : UInt32 = 0x1 << 3
        static let ObstacleC : UInt32 = 0x1 << 4
    } 
PhysicsWorld.contactdelegate = self
func didBeginContact(contact: SKPhysicsContact) {

        var contactbody1 = contact.bodyA
        var contactbody2 = contact.bodyB


        if contactbody1.categoryBitMask < contactbody2.categoryBitMask{

            contactbody1 = contact.bodyA
            contactbody2 = contact.bodyB


        } else {

            contactbody1 = contact.bodyB
            contactbody2 = contact.bodyA

        }

        if ((contactbody1.categoryBitMask == PhysicCategories.BirdC) && (contactbody2.categoryBitMask == PhysicCategories.ObstacleC)){
            // Make a GameOver Function for that!
            // GameOver()


        }
        if ((contactbody1.categoryBitMask == PhysicCategories.BirdC) && (contactbody2.categoryBitMask == PhysicCategories.PlatformC)){

            contactbody1.node.texture = SKTexture(imageNamed: "")



        }
Related Posts Related Posts :
  • NSLogging UILabel's text outputs null
  • undefined reference to '__objc_class_name_Fraction'
  • Move UIView above UITableView when user Scrolls Down
  • adding object to nsmutablearray with custom delegate function giving error
  • Cocoa editing NSBezierPath
  • Perform a action on specific time using Parse
  • Objective-C: How to convert json value to BOOL?
  • How to make an int counter for the days
  • Assigning Label Value with Selected Table View Cell
  • Can dependency injection like Typhoon replace multiple singletons?
  • Objective C - How to determine if a folder is a package?
  • How can one draw a background in the elastic portion of an NSScrollView?
  • A solution for my issue with sending some info from an array to Parse
  • Swift Extension fails adding overloaded methods to Objective-C class
  • Determine if key is incorrect with CCCrypt kCCOptionPKCS7Padding-Objective C
  • PQgetResult always returns NULL
  • self.navigationController? is nil when pushing from a objective-c viewController to a Swift ViewController
  • Where to add subViews that I want floating in an NSScrollView using AutoLayout?
  • 'User' in 'User-defined classes'
  • How to get value of a key in NSDictionary?
  • Adding Border Line to UITableView in StoryBoard
  • Mac App Storyboard - Access Document in NSViewController
  • Objective c, reposition a view above the keyboard in one single animation
  • Dismiss modal segue
  • Error message is saying my data is NULL - NSKeyedUnArchiver - I've followed all the steps - still won't work
  • Remove apostrophe in CFStringTransform results
  • Label showing wrong values while NSLog shows the right ones in SpriteKit
  • How to work with locally modified Cocoapod which don't include podspec?
  • What does kCGWindowSharingState actually do?
  • It is possible to copy a CFTypeRef?
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org