Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
ObjC float2 to ctypes.Structure
-
Hello, for some reasons the y value of float2 ctypes.Structure doesn’t change. You can run the code from link below and check console. What’s causing this and how to fix it?
Here is a code (line 46):
https://gist.github.com/7f46b31bd43959f937b58a54a24e91a0 -
vector_float2
is a native vector type and not a normal struct. Working with vectors requires different CPU instructions than the ones for normal values.ctypes
doesn't support vector types, so I don't think you can use vector types from Pythonista. -
@dgelessus said:
vector_float2
is a native vector type and not a normal struct. Working with vectors requires different CPU instructions than the ones for normal values.ctypes
doesn't support vector types, so I don't think you can use vector types from Pythonista.Thanks for explanation, sounds like it's impossible but I still have a hope. Can you suggest any possible solution? And also could you please check this post regarding SpriteKit contactDelegate issue:
https://forum.omz-software.com/topic/4267/spritekit-problem -
@dgelessus, are you sure?
Looking at the headers for GKAgent2D, that looks like a normal struct. -
@JonB said:
@dgelessus, are you sure?
Looking at the headers for GKAgent2D, that looks like a normal struct.Exactly, since it’s a a normal struct than what can be wrong with my code?
-
Ah, that's an auto-generated header from a class dump or something like that. I was looking at the "real" headers from the iOS SDK, which use vector types. (The iOS SDK headers aren't available online, the closest thing you can see is Apple's online documentation for
GKAgent2D.position
.) I'm guessing that during compilation some "magic" happens to properties/methods that use vector types, and the result is what you see in the class dump header. You could try using the methodsposition_
andsetPosition__
(note the extra underscores), which according to the class dump header use structs instead of vector types. -
@dgelessus said:
Ah, that's an auto-generated header from a class dump or something like that. I was looking at the "real" headers from the iOS SDK, which use vector types. (The iOS SDK headers aren't available online, the closest thing you can see is Apple's online documentation for
GKAgent2D.position
.) I'm guessing that during compilation some "magic" happens to properties/methods that use vector types, and the result is what you see in the class dump header. You could try using the methodsposition_
andsetPosition__
(note the extra underscores), which according to the class dump header use structs instead of vector types.Thank you very much, using the methods with underscore solved the problem!