Game Development Asked by WHY25 on November 2, 2021
Hey guys I need some help I have 2 SkActions.
ball1.run(SKAction.moveTo(y: -self.size.height * 0.2, duration: 1.5))
ball2.run(SKAction.moveTo(y: self.size.height * 1.2, duration: 1.5))
and I want to randomize which one gets called I dont want to run a sequence and no clue how to do it. I’ve tried a switch statement and an enum but that didn’t work.
this is what I have tried. so essentially when I move my player to the right it could be attacked form the top or the bottom.
switch swipeGesture.direction {
case .right:
bat.run(SKAction.moveBy(x: 50, y:0, duration:0.01))
ball1.run(SKAction.moveTo(y: -self.size.height * 0.2, duration:
1.5)) || ball2.run(SKAction.moveTo(y: self.size.height * 1.2, duration: 1.5))
case .left:
bat.run(SKAction.moveBy(x: -50, y:0, duration:0.01))
ball1.run(SKAction.moveTo(y: -self.size.height * 0.2, duration: 1.5)) || ball2.run(SKAction.moveTo(y: self.size.height * 1.2, duration: 1.5))
and it gives me an error: Cannot convert value of type ‘Void’ to expected argument type ‘Bool’
If anybody know how to do so that would be great.
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP