Create(2DAnimations)

pull/25/head
Johan LACHENAL 10 months ago
parent 5b73c5584f
commit 6340d1ba5c

@ -21,6 +21,12 @@
C24659E52BF5FE09004E80D5 /* MainMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = C24659E42BF5FE09004E80D5 /* MainMenu.swift */; };
C25220EE2C00AC7E0026B71F /* GameParametersMenuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C25220ED2C00AC7E0026B71F /* GameParametersMenuView.swift */; };
C2A535D92C0F56A800503472 /* DSQ.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = C2A535D82C0F56A700503472 /* DSQ.xcframework */; };
C2DCC2B42C197BEC008AB78F /* ActionRemove.swift in Sources */ = {isa = PBXBuildFile; fileRef = C2DCC2B32C197BEC008AB78F /* ActionRemove.swift */; };
C2DCC2B62C1980A9008AB78F /* Spark.sks in Resources */ = {isa = PBXBuildFile; fileRef = C2DCC2B52C1980A9008AB78F /* Spark.sks */; };
C2DCC2BA2C19849A008AB78F /* Magic.sks in Resources */ = {isa = PBXBuildFile; fileRef = C2DCC2B82C19849A008AB78F /* Magic.sks */; };
C2DCC2BB2C19849A008AB78F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C2DCC2B92C19849A008AB78F /* Assets.xcassets */; };
C2DCC2BD2C19869B008AB78F /* Fireworks.sks in Resources */ = {isa = PBXBuildFile; fileRef = C2DCC2BC2C19869B008AB78F /* Fireworks.sks */; };
C2DCC2BF2C198702008AB78F /* actionEndGame.swift in Sources */ = {isa = PBXBuildFile; fileRef = C2DCC2BE2C198702008AB78F /* actionEndGame.swift */; };
C2F015092C09D366000F7221 /* LanguageSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = C2F015082C09D366000F7221 /* LanguageSettings.swift */; };
C2F0150C2C09D3A4000F7221 /* KeyboardReadable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C2F0150B2C09D3A4000F7221 /* KeyboardReadable.swift */; };
C2F015102C09D3C3000F7221 /* Language.swift in Sources */ = {isa = PBXBuildFile; fileRef = C2F0150E2C09D3C3000F7221 /* Language.swift */; };
@ -75,6 +81,12 @@
C24659E42BF5FE09004E80D5 /* MainMenu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainMenu.swift; sourceTree = "<group>"; };
C25220ED2C00AC7E0026B71F /* GameParametersMenuView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameParametersMenuView.swift; sourceTree = "<group>"; };
C2A535D82C0F56A700503472 /* DSQ.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = DSQ.xcframework; path = ../NEPASTOUCHER/DSQ.xcframework; sourceTree = "<group>"; };
C2DCC2B32C197BEC008AB78F /* ActionRemove.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionRemove.swift; sourceTree = "<group>"; };
C2DCC2B52C1980A9008AB78F /* Spark.sks */ = {isa = PBXFileReference; lastKnownFileType = file.sks; path = Spark.sks; sourceTree = "<group>"; };
C2DCC2B82C19849A008AB78F /* Magic.sks */ = {isa = PBXFileReference; lastKnownFileType = file.sks; path = Magic.sks; sourceTree = "<group>"; };
C2DCC2B92C19849A008AB78F /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
C2DCC2BC2C19869B008AB78F /* Fireworks.sks */ = {isa = PBXFileReference; lastKnownFileType = file.sks; path = Fireworks.sks; sourceTree = "<group>"; };
C2DCC2BE2C198702008AB78F /* actionEndGame.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = actionEndGame.swift; sourceTree = "<group>"; };
C2F015082C09D366000F7221 /* LanguageSettings.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LanguageSettings.swift; sourceTree = "<group>"; };
C2F0150B2C09D3A4000F7221 /* KeyboardReadable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KeyboardReadable.swift; sourceTree = "<group>"; };
C2F0150E2C09D3C3000F7221 /* Language.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Language.swift; sourceTree = "<group>"; };
@ -131,6 +143,8 @@
82CE59E52C045C7500ADEE24 /* Game */ = {
isa = PBXGroup;
children = (
C2DCC2B72C1980BA008AB78F /* SKAnimations */,
C2DCC2B22C197446008AB78F /* SKActions */,
82CE59EC2C0460AA00ADEE24 /* SKNodes */,
82CE59E82C045D1100ADEE24 /* GameScene.swift */,
82CE59EA2C045E3800ADEE24 /* GameView.swift */,
@ -237,6 +251,26 @@
path = GameParametersMenu;
sourceTree = "<group>";
};
C2DCC2B22C197446008AB78F /* SKActions */ = {
isa = PBXGroup;
children = (
C2DCC2B32C197BEC008AB78F /* ActionRemove.swift */,
C2DCC2BE2C198702008AB78F /* actionEndGame.swift */,
);
path = SKActions;
sourceTree = "<group>";
};
C2DCC2B72C1980BA008AB78F /* SKAnimations */ = {
isa = PBXGroup;
children = (
C2DCC2B52C1980A9008AB78F /* Spark.sks */,
C2DCC2B82C19849A008AB78F /* Magic.sks */,
C2DCC2B92C19849A008AB78F /* Assets.xcassets */,
C2DCC2BC2C19869B008AB78F /* Fireworks.sks */,
);
path = SKAnimations;
sourceTree = "<group>";
};
C2F015072C09D366000F7221 /* Utils */ = {
isa = PBXGroup;
children = (
@ -433,8 +467,12 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
C2DCC2BD2C19869B008AB78F /* Fireworks.sks in Resources */,
C205A2BE2BF373380097BD93 /* Preview Assets.xcassets in Resources */,
C2DCC2BA2C19849A008AB78F /* Magic.sks in Resources */,
C2DCC2B62C1980A9008AB78F /* Spark.sks in Resources */,
C2F0153D2C09D5C0000F7221 /* Localizable.strings in Resources */,
C2DCC2BB2C19849A008AB78F /* Assets.xcassets in Resources */,
C2F015392C09D5A5000F7221 /* Localizable.strings in Resources */,
C205A2BB2BF373380097BD93 /* Assets.xcassets in Resources */,
);
@ -463,6 +501,7 @@
files = (
C2F015112C09D3C3000F7221 /* AI.swift in Sources */,
C2F0152A2C09D420000F7221 /* Stub.swift in Sources */,
C2DCC2BF2C198702008AB78F /* actionEndGame.swift in Sources */,
C2F015252C09D3E7000F7221 /* ItemCollectionParty.swift in Sources */,
C205A2B92BF373360097BD93 /* ContentView.swift in Sources */,
82CE59EF2C0460E500ADEE24 /* SpriteMoople.swift in Sources */,
@ -470,6 +509,7 @@
82CE59E92C045D1100ADEE24 /* GameScene.swift in Sources */,
C2F015242C09D3E7000F7221 /* ProfileComponent.swift in Sources */,
C2F0151E2C09D3E7000F7221 /* PickerComponent.swift in Sources */,
C2DCC2B42C197BEC008AB78F /* ActionRemove.swift in Sources */,
C2F015212C09D3E7000F7221 /* EditImageComponent.swift in Sources */,
C24659E52BF5FE09004E80D5 /* MainMenu.swift in Sources */,
C20310D82BFCC2410031657D /* GeneralParametersMenuView.swift in Sources */,

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "bokeh.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "spark.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

@ -40,7 +40,6 @@ class GameScene : SKScene {
override init(size: CGSize) {
super.init(size: size)
// -- -- //
scaleMode = .aspectFit
anchorPoint = CGPoint(x: 0.5, y: 0.5)

@ -22,7 +22,7 @@ struct GameView: View {
SpriteView(scene: gameScene).task {
gameScene.game.addGameStartedListener { board in startGame()}
gameScene.game.addGameOverListener { board, result, player in gameOver() }
gameScene.game.addGameOverListener { board, result, player in gameOver(result: result) }
gameScene.game.addGameChangedListener { game in gameChange() }
gameScene.game.addBoardChangedListener { board in boardChange() }
@ -50,9 +50,13 @@ struct GameView: View {
func startGame() { print("Start game !")
msg = "Start !!"
}
func gameOver() { print("Game over !")
msg = "Game over !!"
func gameOver(result : Result) { print("Game over !")
// if(result)
msg = "Game over ! "
actionEndGame(scene: gameScene)
}
func gameChange() { print("Game change !") }
func boardChange() {
print("Board change !")
@ -65,11 +69,11 @@ struct GameView: View {
func invalidMove(board:Board,move:Move,player:Player,bool:Bool) {
if (bool){ // Valid
print("Move valid de \(player.id)")
print("Valid move of \(player.id)")
print("Move : \(move.description)")
}
else { // Invalid
print("Move invalid de \(player.id)")
print("Invalid move of \(player.id)")
print("Move : \(move.description)")
gameScene.displayBoard(board: gameScene.game.board)
}
@ -78,10 +82,9 @@ struct GameView: View {
func removePiece(piece:Piece){
print("Remove piece")
if let node = gameScene.pieces[piece.owner]![piece.animal] {
actionRemove(size: gameScene.size, node: node, scene: gameScene)
print("Remove piece from parent")
node.removeFromParent()
}
}

@ -0,0 +1,38 @@
//
// Actions.swift
// ArkitDoushiQi
//
// Created by Johan LACHENAL on 12/06/2024.
//
import Foundation
import SpriteKit
func actionRemove(size : CGSize, node : SpriteMoople, scene : SKScene) {
// Action d'étincelle
let spark = SKAction.run {
createSpark(at: node.position,on: scene)
}
// Séquence des actions
let sequence = SKAction.sequence([spark, SKAction.removeFromParent()])
node.run(sequence)
}
func createSpark(at position: CGPoint,on scene: SKScene) {
// Créer un effet de particule pour l'étincelle
if let sparkEmitter = SKEmitterNode(fileNamed: "Spark.sks") {
sparkEmitter.position = position
scene.addChild(sparkEmitter)
// Retirer l'étincelle après une courte durée
let wait = SKAction.wait(forDuration: 1.0)
let remove = SKAction.removeFromParent()
let sequence = SKAction.sequence([wait, remove])
sparkEmitter.run(sequence)
}
}

@ -0,0 +1,42 @@
//
// actionEndGame.swift
// ArkitDoushiQi
//
// Created by Johan LACHENAL on 12/06/2024.
//
import Foundation
import SpriteKit
func actionEndGame(scene : SKScene) {
let size = scene.size
for _ in 0..<5 {
// Créer un effet de particule pour les feux d'artifice
if let fireworkEmitter = SKEmitterNode(fileNamed: "Spark.sks") {
// Position aléatoire pour chaque feu d'artifice
let randomX = CGFloat.random(in: 0..<size.width)
let randomY = CGFloat.random(in: 0..<size.height / 2) + size.height / 2
fireworkEmitter.position = CGPoint(x: randomX, y: randomY)
// Changer la couleur des particules
fireworkEmitter.particleColor = randomColor()
fireworkEmitter.particleColorBlendFactor = 1.0
scene.addChild(fireworkEmitter)
// Retirer le feu d'artifice après une courte durée
let wait = SKAction.wait(forDuration: 2.0)
let remove = SKAction.removeFromParent()
let sequence = SKAction.sequence([wait, remove])
fireworkEmitter.run(sequence)
}
}
}
func randomColor() -> UIColor {
let red = CGFloat.random(in: 0...1)
let green = CGFloat.random(in: 0...1)
let blue = CGFloat.random(in: 0...1)
return UIColor(red: red, green: green, blue: blue, alpha: 1.0)
}

@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "bokeh.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "spark.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading…
Cancel
Save