Tag Info

Hot answers tagged

2

Your question is a good one. I've had exactly the same question regarding SpriteKit and have been very confused about the lack of information on the web about this. SpriteKit seems to encourage you to put all of your Model-View-Controller code into the same class (your SKScene subclass), which is really confusing to me. How would you ever build a game of ...


1

Your drawings seem inconclusive with respect to axis names and signs. Just going by the first illustration, you could say approximately: _playerSpeedY = 2 _playerSpeedX = -1 // going to the left, negative! radians = atan2(_playerSpeedY, _playerSpeedX) degrees = radians * 57.29577951 I get radians = 2.0344439357957027 and degrees = 116.56505117080718 ...


1

I was misunderstanding the way vectors in SpriteKit are represented. The solution I used was: dx = (size.width / 2 - ball.position.x) * vel dy = (size.height / 2 - ball.position.y) * vel


1

I can see you going about this two ways without changing too much of your core data model. Kind of a lazy way to do it if you know that there will be no more than 3 bonuses per item. bonus_1_type (NSInteger) bonus_1_amount (float) bonus_2_type bonus_2_amount bonus_3_type bonus_3_amount This would give you the flexibility to use an Enum for type and ...


1

That is a fine way to do it. Alternatives would be A field on the item specifying which attribute the bonus applies to, with a modifier ie [{"fire_rate", 5}, {"health", 10}] Each item could have a pair of delegates so you can make changes programatically. One applies the item's attributes, and optionally, the other removes them (like for equipment) ...


1

If you want a velocity of 800, you actually don't want x and y to add up to 800, you wan't the vectors length to be 800. If you already have the correct direction, you could normalize the vector, which would then be a unit-vector (length 1) and multiply this unit-vector by any scalar (number) you want to get the length you need, for example: int ...



Only top voted, non community-wiki answers of a minimum length are eligible