Showing posts with label Sprite Kit. Show all posts
Showing posts with label Sprite Kit. Show all posts

Tuesday, March 6, 2018

Swift Tutorial Animation the Knight in RPG game

In this tutorial, we will learn:
+ Create animation with texture atlases
+ Change the direction the bear faces based on the moving location
+ Make the ninja move to the touch location
+ Knight will stand and move

# Create the Swift Project
To start the tutorial, you need to create a Swift Project.
Start up you Xcode, select File\New\Project… (if there is no project), choose the iOS/Game Template and click on Next Button.

Game Project with Sprite Kit

Enter LapKanAnimationKnight for the Product Name.
Choose Swift for Language (Important)
Sprite Kit for Game Technology.
Next to create Project.

=> We have a ready project to start.

# Download the asset: Link

These images from Tokegameart, they are really good for RPG Games, so if you see this is good assets, buy from them, they are royal free.
Dark Knight Atlas


# Texture Atlases:

Copy these asset to Project.
Drag and drop these file to the project.

# Make simple animation first:
Create the variable for code:

private var knight = SKSpriteNode()
 private var knightWalkingFrames: [SKTexture] = []
 private var knightIdleFrames: [SKTexture] = []

# Setting up the Texture Atlas:
Now, we write the code to set the texture for each action
Action for walking from 0 -> 23.
Action for standing from 0 -> 17.
If you have more actions, you need to write more code for each action.

func buildKnight() {
        let knightAnimatedAtlas = SKTextureAtlas(named: "DarkKnight")
     
        // Walking Frames
        var walkingFrames: [SKTexture] = []
        for i in 0...23 {
            let knightTextureName = String(format: "Walking_%03d", arguments: [i])
            walkingFrames.append(knightAnimatedAtlas.textureNamed(knightTextureName))
        }
        knightWalkingFrames = walkingFrames
     
        // Idle Frames
        var idleFrames: [SKTexture] = []
        for i in 0...17 {
            let knightTextureName = String(format: "Idle_%03d", arguments: [i])
            idleFrames.append(knightAnimatedAtlas.textureNamed(knightTextureName))
        }
        knightIdleFrames = idleFrames
}

So we have the function buildNinja, now the only thing we need to create a ninja is use

func animatedKnight() {
        knight.run(SKAction.repeatForever(SKAction.animate(with: knightWalkingFrames, timePerFrame: 0.03, resize: false, restore: true)), withKey: "walkingInPlaceKnight")
}

# Make Stand Frames:
After the knight go to the goal point, we remove all action and set the action for standing.
func knightStand() {
        knight.removeAllActions()
        knight.run(SKAction.repeatForever(SKAction.animate(with: knightIdleFrames, timePerFrame: 0.03, resize: false, restore: true)), withKey: "idleInPlaceKnight")
}

# Change Animation Facing Direction
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
        for t in touches { self.touchUp(atPoint: t.location(in: self)) }
   
        let touch = touches.first!
        let location = touch.location(in: self)
   
        moveKnight(location: location)
}

# Make Knight Moving:

func moveKnight(location: CGPoint) {
        if knight.action(forKey: "idleInPlaceKnight") != nil {
            knight.removeAction(forKey: "idleInPlaceKnight")
        }
   
        var multiplierForDirection: CGFloat
   
        let knightSpeed = frame.size.width / 3.0
   
        let moveDifference = CGPoint(x: location.x - knight.position.x, y: location.y - knight.position.y)
        let distanceToMove = sqrt(moveDifference.x * moveDifference.x + moveDifference.y * moveDifference.y)
   
        let moveDuration = distanceToMove / knightSpeed
   
        if moveDifference.x < 0 {
            multiplierForDirection = -1.0
        } else {
            multiplierForDirection = 1.0
        }
   
        knight.xScale = abs(knight.xScale) * multiplierForDirection
   
        if knight.action(forKey: "walkingInPlaceKnight") == nil {
            animatedKnight()
        }
   
        let moveAction = SKAction.move(to: location, duration: (TimeInterval(moveDuration)))
        let doneAction = SKAction.run( {
          [weak self] in self?.knightStand()
        })
   
        let moveActionWithDone = SKAction.sequence([moveAction, doneAction])
        knight.run(moveActionWithDone, withKey: "knightMoving")
}


Full Code Done: Link

Friday, November 25, 2016

Animal Game: More thing about animals

Do you know the best way to remember something is playing with them a lot?
Kid can learn very fast but they don’t spend so much time on these thing.
The great way for you to make the children can learn is let them interesting with these items through the great image and sound on this.

This game will help you to make your children have interesting with animals. These game is simple but will make them happy with cute animals.

Let you children know more about animal
+ What food they eat
+ Where they live
+ Different type with other thing
+ Drag and drop the animal to their shadow

Download: Link





Thursday, September 1, 2016

Word Play: Sea Fishes

Do you know the best way to remember something is playing with them a lot?
Kid can learn very fast but they don’t spend so much time on these thing.
The great way for you to make the children can learn is let them interesting with these items through the great image and sound on this.

This game will help you to make your children have interesting with sea animals. Each sea animal have its name and cute image will make your children remember better. These game is simple but will make them happy with cute sea animals. Have a good time with your family.

There is testing mode that help children can check their memory.

By making full words, children will learning natural without any trying. After 10 times play, they will remember the words and pictures very well. You can check them. The only hard thing is make this usually.

Feature:

- 25 sea fishes word can make them remember very well.
- Can pronoun and let the kid learning.
- Learning Scene with word on image
- Playing Scene with word on image
- Learning Scene with word on image

Note: This app is done with Sprite Kit, the best framework for game from Apple.

Download: Link





Sunday, August 28, 2016

Word Play: Junior Animals

Do you know the best way to remember something is playing with them a lot?
Kid can learn very fast but they don’t spend so much time on these thing.
The great way for you to make the children can learn is let them interesting with these items through the great image and sound on this.

This game will help you to make your children have interesting with animal. Each animal in the card with its name and cute image will make your children remember better. These game is simple but will make them happy with cute animals. Each junior animal have the familiar background and easy to teach them about this animal. Have a good time with your family.

By making full words, children will learning natural without any trying. After 10 times play, they will remember the words and pictures very well. You can check them. The only hard thing is make this usually.

Feature:

- 26 junior animals can make them remember very well.
- Can pronoun and let the kid learning.

Note: This app is done with Sprite Kit, the best framework for game from Apple.

Download: Link






Saturday, August 27, 2016

Healthy Me: Bacteria Around You

Bacteria is all around us. Some of them are good but some of them are bad.

Children don't know their exist. With this game, you can show them, bacteria is all around. This is scary but let children clear their hands and touch on these bacteria, they will disappear. So they will not scare them any more.

Download: Link






Friday, August 26, 2016

Word Play: Amazon Rainforest

Do you know the best way to remember something is playing with them a lot?
Kid can learn very fast but they don’t spend so much time on these thing.
The great way for you to make the children can learn is let them interesting with these items through the great image and sound on this.

This game will help you to make your children have interesting with animals in Amazon Rainforest.
You will play with your kid about the animals name in Amazon Rainforest.

Don’t worry, their names are in the pictures. You will have time fun with your kids.

Download: Link






Thursday, August 25, 2016

Word Play: Safari Animals

Do you know the best way to remember something is playing with them a lot?
Kid can learn very fast but they don’t spend so much time on these thing.
The great way for you to make the children can learn is let them interesting with these items through the great image and sound on this.

This game will help you to make your children have interesting with animals in Safari.
You will play with your kid about the animals name in Safari.

Don’t worry, their names are in the pictures. You will have time fun with your kids.

Link: Download






Monday, August 22, 2016

Learning Me: Junior Picture Alphabet


Do you know the best way to remember something is playing with them a lot?
Kid can learn very fast but they don’t spend so much time on these thing.
The great way for you to make the children can learn is let them interesting with these items through the great image and sound on this.

This game will help you to make your children have interesting with animal. Each animal in the card with its name and cute image will make your children remember better. These game is simple but will make them happy with cute animals. Each junior animal have the familiar background and easy to teach them about this animal. Have a good time with your family.

Feature:

- 26 junior animals can make them remember very well.
- Can pronoun and let the kid learning.
- Matching Card game help children recognise the similar cards.
- Finding Card game find all funny english character cards will make them more interesting.
- Voice Game with help children can hear and know exactly the character in alphabet.
- Matching Character allow them to drag and drop.
- Find One let them find the special animal that lost among the other

Note: This app is done with Sprite Kit, the best framework for game from Apple.

Download: Link






Friday, August 19, 2016

Learning Me: Learning Alphabet With Animals

Do you know the best way to remember something is playing with them a lot?
Kid can learn very fast but they don’t spend so much time on these thing.
The great way for you to make the children can learn is let them interesting with these items through the great image and sound on this.

This game will help you to make your children have interesting with animal. Each animal in the card with its name and cute image will make your children remember better. These game is simple but will make them happy with cute animals. Each junior animal have the familiar background and easy to teach them about this animal. Have a good time with your family.

Feature:

- 26 junior animals can make them remember very well.
- Can pronoun and let the kid learning.
- Matching Card game help children recognise the similar cards.
- Finding Card game find all funny english character cards will make them more interesting.
- Voice Game with help children can hear and know exactly the character in alphabet.
- Matching Character allow them to drag and drop.
- Find One let them find the special animal that lost among the other

Note: This app is done with Sprite Kit, the best framework for game from Apple.

Download: Link






Tuesday, August 16, 2016

Learning Me: Junior Animals

Do you know the best way to remember something is playing with them a lot?
Kid can learn very fast but they don’t spend so much time on these thing.
The great way for you to make the children can learn is let them interesting with these items through the great image and sound on this.

This game will help you to make your children have interesting with wildlife. The animals in the card with their name and cute image will make your children remember better. These game is simple but will make them happy with cute animals. Each junior animal have the familiar background and easy to teach them about this animal. Have a good time with your family.

Feature:

- 26 junior animals can make them remember very well.
- Can pronoun and let the kid learning.
- Matching Card game help children recognise the similar cards.
- Finding Card game find all funny english character cards will make them more interesting.
- Voice Game with help children can hear and know exactly the character in alphabet.
- Matching Character allow them to drag and drop.
- Find One let them find the special animal that lost among the other

Note: This app is done with Sprite Kit, the best framework for game from Apple.

Download: Link

Learning with junior animal








Monday, August 15, 2016

Learning Me: Cartoon Alphabet Character

Do you know the best way to remember something is playing with them a lot?
Kid can learn very fast but they don’t spend so much time on these thing.
The great way for you to make the children can learn is let them interesting with these items through the great image and sound on this.

These games will help you to make your children have interesting in learning alphabet character. There are 26 cartoon images for each character in alphabet with bright colour. This will be easy to record in children memory with simple and colourful english images like that. They include the voice to make your children can remember both alphabet character, image, words and pronoun.

Matching Game will make them play longer and the only goal is let them play and remember the fruit and the character.
Voice Game will combine the image and the voice, they can hear and decide what word is.
Finding Game make them remember images try to find all of these on the screen.
Match Character let them drag and drop the image and the cartoon character.

Feature:

- 26 cartoon alphabet characters.
- Can pronoun and let the kid learning.
- Matching Card game help children recognise the similar cards.
- Finding Card game find all funny english character cards will make them more interesting.
- Voice Game with help children can hear and know exactly the character in alphabet.
- Matching Character allow them to drag and drop.

Note: This app is done with Sprite Kit, the best framework for game from Apple.

Download: Link