Players spamming jump does not trigger Touched" event - lua

So I'm making a sort of spleef type game where players jump around as blocks disappear beneath them. However, if you just hold down the space bar, Roblox doesn't seem to register the "Touched" event. Can anyone help?
Here is my script for each of the disappearing platforms:
local platform = script.Parent
local function fade()
print("Touched!")
platform.Transparency = 1
platform.CanCollide = false
end
platform.OnTouched:Connect(fade)

A BasePart doesn't have an event named "OnTouched", but I think you are referring to "Touched" event of BasePart.
You can change the platform.OnTouched:Connect(fade) to platform.Touched:Connect(fade)
https://developer.roblox.com/en-us/api-reference/event/BasePart/Touched

With new r15 anthro models, sometimes the touch won't register as the hitbox fails to register a touch.
What I did a long ago was to create an invisible box with no collision that is thin above the part that you would like to touch, then check the .Touched event in the invisible box instead the one you are checking right now.

Related

In React Native is there a way to recognize stylus (pen) vs touch (finger) event?

I'm working on the RN application that has one screen with a list of "drawable" areas in it. So this screen should be scrollable AND drawable.
What I'm trying to do - is to find a solution to distinguish touch events coming from fingers (these will be used to scroll and disallow drawing) and stylus via Apple Pencil (these will be used to draw and disallow scrolling).
In both Gesture Responder and PanResponder there are events being passed on each move. Each of those events (alongside with the nativeEvent) contains the type property. However, it's always null for me in both simulator and device.
Is there any way to recognize a move event as a finger vs stylus?
We had a similar requirement for one of our projects, and what we did was to use a Pressable component, to which a handlePress function was passed as prop.
This function accepted the GestureResponderEvent as event callback argument.
By using the event.nativeEvent.altitudeAngle property that was added recently, we were able to detect Apple Pencil touches.
function handlePress(event: GestureResponderEvent) {
//#ts-expect-error React Native Types do not include altitudeAngle
const isPencilTouch = !!event.nativeEvent.altitudeAngle;
...
}

Xcode/Objective-C implementing a players turn toggle

I'm new to the whole VCM programming structure and more specifically to objective-c.
Right now i'm working on an iOS app that is like the game "connect 4." This Xcode project is my practice project that i've been using to play around/learn how to make iOS apps so there are several files and lots of commented out code, so Ill try my best to provide the necessary content from my project.
App State:
Right now I have a 10x10 grid of blue square/buttons. I'm still in the early stages of implementing the functionality of the game. Rather than making each square its own button, I created 10 frames and 10 buttons. Each row is a single button, which is broken up into 10 squares.
I currently have the squares change their color to red and become disabled once clicked. If I click multiple times.. the squares turn red when pressed. Heres a screenshot example run:
What Im wanting to do:
I want to build off of what I have, but not exactly sure how to keep track of which "players turn" it is. For example.. I want the first clicked square to turn red, representing player1's move. I want the second click to turn the button, say green, representing player2's move.. then the next move will be player 1's move.
I know Ill have to make sure the button is/was ENABLED and valid before switching which players turn it is.
How should I go about doing this? This is more of a general question, but I'll provide needed code snippets if necessary. Thanks!
In your .h file add an integer (variable)
int Turn = 1;
In your .m file you can do:
if(Turn == 1)
{
// Player one is playing
Turn = 2;
}
else if(Turn == 2)
{
// Player two is playing
Turn = 1;
}

iPad CSS3 webkitTransform and touch events - a slight unexplained stutter

This is pertaining to an image gallery, so as you "swipe", images are loaded and unloaded off of the screen, but the center image always appears smoothly.
It is code derived from the swipeview library described here: http://cubiq.org/swipeview
The problem is that, there is a 100-200ms delay which occurs between when the javascript sets the webkitTransform in the touch end event, and when the element actually starts animating on the screen.
This problematic delay, only happens intermittently; it seems that it starts happening consistently after about 15-20 slides have been unloaded/loaded.
In the touch move event there is code like this:
element.style.webkitTransitionDuration = 0
element.style.webkitTransform = "translate3d( etc. ) "
And this functions very fast, such that if you move your finger around on the ipad, the element follows your finger precisely and "instantly".
And in the touch end event there is code like this:
element.style.webkitTransitionDuration = '<some_number>ms';
element.style.webkitTransform = "translate3d( etc. ) "
And the touch end event is where the problem is. The touch End event itself fires the instant the finger is removed from the ipad, however, when the problem is happening, the css update doesnt trigger an actual animation on screen until after the problematic delay mentioned above.
This was a tricky one. I finally found the culprit. In my touchend event listener, I was calling a function that added classes to DOM elements. This caused Safari to take a moment to rewire textures to the GPU, resulting in the stutter. Removing those direct className updates made it all buttery smooth again (and I'm still using requestAnimationFrame and not CSS transitions).
I moved my className changes to a separate event that fired from touchend instead and it didn't cause any performance issues. So, if you must set classes, just don't do it directly in the touchend callback. Trigger another event instead or set the classes in requestAnimationFrame.

Can I disable multitouch for a Windows Phone Application?

I'm currently working on a game for Windows Phone 7, using the XNA version of Cocos2d.
Due to the rules of the game, I need it so that the user can only touch one thing at a time but multitouch seems to be always in effect. Additionally I don't know if this is a Cocos error, but it also causes the game to behave erratically (responding to a single touch like they were many).
I guess I would have to correct every touch event of the game one by one, but I was wondering if I can use something to disable multitouch quickly, or reduce the number of touches accepted to one at a time.
I'm not sure about Cocos2d-x for XNA. But in regular XNA if you want to force only single-touch input, the simplest way to that is by using the Mouse class. In a touch environment it is still available - emulated by using touches. It only responds to a single touch at a time.
Each frame you can get the list of touches. Since their management is delegated to your code, just ignore them if you have more than one. Another option is only using the first one, remember its TouchID and ignore all the rest.
I've used the first option when porting mouse applications over to the phone.
Cocos touch input has to be treated somewhere in the game, in accessible code, so you should have access to their point of entry.
Yes, you can do this with Cocos2D-XNA. You set the TouchMode to be either OneByOne, or AllAtOnce. OneByOne will give you the single CCTouch signature methods, and AllAtOnce will get you the List signature methods.
public MyCtor() {
TouchEnabled = true;
TouchMode = CCTouchMode.OneByOne;
}
public override bool TouchBegan(CCTouch t) {
}
public override void TouchMoved(CCTouch t) {
}
public override void TouchEnded(CCTouch t) {
}
Now you only get one touch at a time. There's no way to disable the touch pad's delivery of all touches from all fingers though. As another user mentioned, you would just ignore those.
Remember that you get a touch ID with every touch, which works to match the touch data with each began, moved, ended event call. I suggest you make use of touch ID as well to ensure that you are processing only the touches that you want.

XNA - Cannot See Mouse in Game

I've recently started checking out XNA. All is going well and I've even got a working sample started. One thing that's been bugging me is that whenever I place my mouse over the game window it disappears. I don't know if this is the default behavior but I would like to change this so that I can see my mouse. Any and all advice is appreciated.
Simply set IsMouseVisible to true in your main game class(preferably in your Initialize method or Game class constructor) :
IsMouseVisible = true;

Resources