sknode

Modify property on SKNode while moving

匆匆过客 提交于 2019-12-01 13:48:35
I have a subclass of SKNode that acts as my "creature". These move about the scene automatically using SKActions. I'm interested in modifying (decreasing) an 'energy' property (Int) as the creature moves. The creature isn't guaranteed to move the entire length of the move SKAction (it can be interrupted), so calculating the total distance and then decreasing the property as soon as it starts moving isn't ideal. I'd essentially like to say "for every 1 second the node is moving, decrease the energy property". How can I do this? I'm at a loss! Thank you. In your GameScene.swift class you have an

Modify property on SKNode while moving

穿精又带淫゛_ 提交于 2019-12-01 12:26:36
问题 I have a subclass of SKNode that acts as my "creature". These move about the scene automatically using SKActions. I'm interested in modifying (decreasing) an 'energy' property (Int) as the creature moves. The creature isn't guaranteed to move the entire length of the move SKAction (it can be interrupted), so calculating the total distance and then decreasing the property as soon as it starts moving isn't ideal. I'd essentially like to say "for every 1 second the node is moving, decrease the

Can't tap SKSpriteNode - no touch detected ios

不羁岁月 提交于 2019-12-01 01:54:48
问题 I am pretty new to iOS, objective C and working with Xcode. I only did one simple news type app, but now I would like to create a game I had published on another platform. Basically, I have one object that will appear randomly and then fade out and the purpose is to tap on the object to make it go away. However I can't seem to tap the object, even though I set mySKSpriteNode.userInteractionEnabled = YES; Here is what I have in my touchesBegan method: -(void)touchesBegan:(NSSet *)touches

SKNode position not working, always going to default 0,0

独自空忆成欢 提交于 2019-11-30 20:24:21
I have fairly well developed SpriteKit game I'm working on, added some code to add a new SKSpriteNode to the Scene, (same as I have done dozens of other places in the code, but for some reason this time it is just ignoring the position I have set for the node, I have tried it by explicit .position = CGPointMake(x,y) and trying the [node setPosition:CGPointMake(x,y)] Neither work... the node does get added to the scene, but ALWAYS at 0,0, no matter what I do, have checked both the x and y to make sure they are valid and in the range of the scene, and tried to use explicit floats etc, and it

SpriteKit missing linear transformation matrices

廉价感情. 提交于 2019-11-30 19:14:36
问题 Does anyone know how to transform ( rotate , scale , skew ) SpriteKit nodes using transformation matrices. couldn't find any support for this in the Spritekit API. 回答1: As mentioned by Fogmeister, you can use an SKEffectNode with a CIFilter. The following works on iOS: // Label let label = SKLabelNode(text: "Hello world") // Transform let transform = CGAffineTransformMake(1, 0.5, 0, 1, 0, 0) // CIFilter let transformFilter = CIFilter(name: "CIAffineTransform")! let val = NSValue

SpriteKit: detect complete node overlap

亡梦爱人 提交于 2019-11-30 13:34:49
问题 I have two SKShapeNodes – one with an edge-based SKPhysicsBody, one volume-based – and I want to detect their intersection without collision. I've got this working fine, with the SKPhysicsContactDelegate contact methods getting called as one passes over another, but my issue is that didEndContact gets called when the edges no longer intersect, even when one body is completely contained within the other. What's the best way to determine true contact or overlap, not just edge intersection? I've

Subclassing SKNodes created with SpriteKit .sks scene file

£可爱£侵袭症+ 提交于 2019-11-30 08:11:34
问题 (this is for XCode 6 and iOS 8 beta 4) Love the new SceneKit editor. I'm successfully loading the scene from .sks file into a custom SKScene class. However, objects inside it are instantiated as default classes (SKNode, SKSpriteNode, etc), and i'm not sure how to bind them to be instantiated as custom subclasses instead. Currently, I'm getting around that by creating custom classes and linking to sprite nodes as a property, and that works ok 回答1: I wrote a little helper delegate to deal with

SpriteKit: detect complete node overlap

懵懂的女人 提交于 2019-11-30 07:42:07
I have two SKShapeNodes – one with an edge-based SKPhysicsBody, one volume-based – and I want to detect their intersection without collision. I've got this working fine, with the SKPhysicsContactDelegate contact methods getting called as one passes over another, but my issue is that didEndContact gets called when the edges no longer intersect, even when one body is completely contained within the other. What's the best way to determine true contact or overlap, not just edge intersection? I've tried usesPreciseCollisionDetection , to no avail. CGPoint locObj1 = [sprite1 locationInNode:self];

SKNode position not working, always going to default 0,0

本秂侑毒 提交于 2019-11-30 05:19:07
问题 I have fairly well developed SpriteKit game I'm working on, added some code to add a new SKSpriteNode to the Scene, (same as I have done dozens of other places in the code, but for some reason this time it is just ignoring the position I have set for the node, I have tried it by explicit .position = CGPointMake(x,y) and trying the [node setPosition:CGPointMake(x,y)] Neither work... the node does get added to the scene, but ALWAYS at 0,0, no matter what I do, have checked both the x and y to

applyImpulse towards CGPoint SpriteKit

懵懂的女人 提交于 2019-11-29 13:03:05
I'm kind of a newb in SpriteKit, game dev, as a matter of fact I'm just learning. So I got to a point where I what to move a bunch of nodes towards a users tap location. So far I fought that I might calculate a virtual right triangle and get sin and cos of angles based on the sides. Unfortunately that left me with a very strong impulse that doesn't really consider the user tap location. Any ideas? Thanks in advance. Look up the shooting projectiles section in the tutorial by Ray Wenderlich here: http://www.raywenderlich.com/42699/spritekit-tutorial-for-beginners Change the code from the