Xcode visible part of PNG-Image (SpriteNode) as touchable area - ios

I am currently working on a new project and I need to detect whether my SpriteNode has been touched or not. That is not the problem [yet]. But my SpriteNode includes an Png-Image and due to this it also includes an translucent part. And what I want to do is to "delete"/ignore this non-visible part and only detect whether the visible part has been touched. I tried it on several ways but nothing really worked. I need an reliable way to do that (Swift 4 or 3). I already read other posts but they did not help.
Or maybe you have other ways to determine an touchable area from Png-Image than using a SpriteNode.

Related

Detect tap on a label in Mapbox map on iOS

I'd like to know if there is a way to best detect a users tap on a label?
The new iOS15 Maps app allows a tap on e.g. a cities name and then shows informations about that city.
I am now wondering if something similar can be done with mapbox?
I know that there is a mapView.visibleFeatures(in: myRect) function that can somehow help here. So I can convert my finger location to a rect and then get all features there.
BUT... my city e.g. might have a label that is let's say 200 px wide. So I would need to have a quite large rect to find the point of my city label. And then I will also get all kinds of other labels that might be there. Maybe even not visible, but in the dataset.
Is there no way to ask the map what the frontmost element was when I tapped? So that when I tap on the far end of the label, I still get that ONE feature?
I am still using Mapbox V6.3... the latest before their last major update.
But if it's not possible with that version, an answer about the latest V10.something would also be great.
For v10, this example demonstrates how to identify features near a click. While the overall example is to a different end, the onMapClick functions shows the method to find a feature and then build an annotation.
https://docs.mapbox.com/ios/maps/examples/view-annotation-marker/

Can I add button on Map in watchkit?

I'm trying to build an app for Apple Watch OS 2, so I was wondering is it possible to add buttons or images on top of the map?
As far as I know, there isn't such a thing like "multiple layers", as you might call it, which would allow you to arrange a thing on top of another thing, in WatchOS yet.
So, I don't think, that the thing you want would work, sorry.
You would need to do your own tile rendering to do something like that. I have four buttons over the top of my maps and I render custom waypoints and routes on the map. To do that I have a custom tile render that generates an image that I set for the watch background and then I overlay buttons on top of it. Here is some more info on how I overlay the buttons Is it possible to position views on top of each other. (One thing that has changed since that post is that I no longer break the background up into four images, I can just set the background as a single image. Somehow I missed that when I initially read the API docs. Also, I turned off the animations for watchOS 1 and I have them on for watchOS 2.)

Animating a "character" within iOS app that's not SpriteKit

I am in talks with a client to do an app, but in it, they are wanting it to revolve around a little character that follows you throughout the app (think Clippy, from the old days of Microsoft Word :)).
One thought I had was, can I use an SKSprite/Node inside an iOS app not using the SpriteKit framework?
Or is this a matter of animating through an array of UIImages?
Those were my first thoughts - does anyone know the best direction to go in for something like this? I need basic animations for a character throughout the whole app.
Depending on the detail of animation needed, you could do it with just CoreAnimation and possibly selectively choosing the image to display in an UIImageView. For example, see the answers to this question: rotate a UIView around its center but several times
Simple answer is, No, out of the box you can't use a class from a framework and choose to not use the framework. Though I'm not exactly sure what that question means. An SKSpriteNode renders via an SKScene node, and an SKScene node renders via an SKView, which is rendered by a View Controller.
You could do something fancy like dedicate the SKView as only part of the screen, and have a standard UIKit view as the other part, or only have the SKView appear on the screen when you needed it I guess.

How can i stack up tiles in iOS programming?

I'm trying to learn iOS programming and I decided to make a game like Connect 4, or some may know it as Four in a row.
I've done the grid and dropping the tiles. However, I haven't been able to stack the tiles on top of each other. I havent tried that much because I have no idea on how i could do something like that as i have never tried making a game like this, I have also searched online but I dont know if it's my choice of wording that it never shows anything or if there isnt anything like it.
I have 7 column on the top, with a hairline where you touch in order to drop the tile to the grid. Right now the tiles just stack on each other.
Not sure if my response is worth to be an answer but what the heck...
If you are set on not getting into Sprite Kit right now, you could probably use UIButton to make this happen. Divide your screen into a grid of UIButtons. You can set the button images according to empty and played (red or blue). Each button code would have to check for things like if the hole (button) was already played, what color chip to display, is this a winning move, etc... There is of course an easier way to do this instead of copying the same code into each button but I'll let you try to figure that one out for now.

Delphi iOS touch points

I am wanting to get the touch points in an iOS app under Delphi (preferably as an event).
Is there an interface for this that is exposed?
I found this:
Get touch points in UIScrollView through UITapGestureRecognizer.
But I would not know if its possible to convert this code.
I am trying to implement a number of on-screen sliders (audio faders) so that the user and slide their finger to move it up and down. I plan to put a transparent rectangle control over top of the sliders so that I can get multiple touch points and move more than one simultaneously.
After going down this rabbit hole about as far as possible I am sad to say that's its not possible to get multiple touch points in Delphi. This is very shortsighted and appears to be a trivial oversight by Embarcadero.
Essentially the Delphi UIView implementation does not expose the "multipleTouchEnabled" property so the touch events inside of FMX.Platform.iOS.pas will never receive more than one touch event.
I am posting this to save the next person the time that I put into find this disappointing answer.

Resources