ios - Assigning different emitters to different nodes that are randomized -


i have basic emitter nodes working in first app. have created constants file references nodes throughout game, , converts them strings. great mini data base. basic whack mole game, except have 12 different characters.

gamescene code

this called in didmovetoview method:

 func star(pos: cgpoint) {         let emitternode = skemitternode(filenamed: "star.sks")         emitternode!.particleposition = pos         self.addchild(emitternode!)         self.runaction(skaction.waitforduration(2), completion:             {emitternode!.removefromparent() })     } 

this called in touchesdidbegin method:

if node.name == "charenemy" {                  let whackslot = node.parent!.parent as! whackslot     if !whackslot.visible { continue }     if whackslot.ishit { continue }     star(touchlocation)     whackslot.hit()     ++score } 

i created own custom class whackslot handle charenemy node , charfriend:

let name = barray[int((randomfloat(min: 0.0, max: float(barray.count))))]         charnode.texture = sktexture(imagenamed: name)         charnode.name = "charfriend"         charnode.id = name      } else {         charnode.texture = sktexture(imagenamed: aarray[int((randomfloat(min: 0.0, max: float(aarray.count))))])         charnode.name = "charenemy"         charnode.id = ""     } 

i created custom class slot:

import uikit import spritekit  class slot: skspritenode {      var id:string? } 

so pulls data constants file textures have been converted in strings:

struct constants {     struct dev {         static let  debug = false     }      struct zoo {          struct animal {              struct dog {               static let  name = "dog"                static let image = "d1"              }             struct donkey {                 static let  name = "donkey"                 static let image = "d2"               }             struct cat {                 static let  name = "cat"                 static let image = "d3"             }              static let zoo = [dog.image,donkey.image,cat.image]          } 

i have image represents skaction plays audio file correlating constants file. instead of giving stars @ touch location have each image have own emitter.

things have tried point: endless tutorials, rw, cartoon smart. have 1 emitter working, , can assign different emitter charfriend , charenemy yet can assign each individual animal own emitter, tried adding in struct constants, no dice, tried if-else statements breaking out each image yet charfriend supersedes , same charenemy,

this , adding array of sounds in constants each individual image hang ups.

any suggestions helpful. have hardcoded game scene, version 2 done in spritekit scene editor. last past of "juice" before submit first app app store. guidance appreciated.

legacy eternal.

latest software being used.

a little tip learned long journey, if make game scene same size apple tv universal assets @1x optimized devices, , weird ipad screen extend bgnode little above parameters , automagically convert fit well.

although nice think can have random particles each spritenode, (mine in array of images converted strings) found best approach break out each individual node in array. called creating multiple game scenes, nodes, wanted have emitters being represented individually. particles eat lot performance, short burst, still cool, , effective. adjusting life time settings, achieved desired effect.

i decided use editor, see results in real time.

it enjoyable see type of effects, can make, , manipulating ranges in reach across play screen. here on created making fire, smoky effect @ end. using alpha scale, determine how color, shows , where, how fast color presents itself.

my main lesson break out nodes out of array, , created different logic without ruining gaming experience.


Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -