1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-11-09 00:04:42 +00:00

touch controls in progres

This commit is contained in:
Cameron Taylor 2021-08-22 10:37:06 -04:00
parent 1992d5363e
commit 61ba71d3db
4 changed files with 75 additions and 0 deletions

View file

@ -3,12 +3,17 @@ package;
import flixel.input.FlxInput;
import flixel.input.actions.FlxAction;
import flixel.input.actions.FlxActionInput;
import flixel.input.actions.FlxActionInputAnalog.FlxActionInputAnalogClickAndDragMouseMotion;
import flixel.input.actions.FlxActionInputDigital;
import flixel.input.actions.FlxActionManager;
import flixel.input.actions.FlxActionSet;
import flixel.input.gamepad.FlxGamepadButton;
import flixel.input.gamepad.FlxGamepadInputID;
import flixel.input.keyboard.FlxKey;
import flixel.input.mouse.FlxMouseButton.FlxMouseButtonID;
import flixel.ui.FlxVirtualPad;
import flixel.util.FlxColor;
import flixel.util.FlxTimer;
/**
* Since, in many cases multiple actions should use similar keys, we don't want the
@ -611,8 +616,15 @@ class Controls extends FlxActionSet
case None: // nothing
case Custom: // nothing
}
trace('added virtual controls!?');
trace(virutalPad);
if (FlxG.onMobile) {}
}
var virutalPad:FlxVirtualPad;
function removeKeyboard()
{
for (action in this.digitalActions)
@ -689,6 +701,14 @@ class Controls extends FlxActionSet
forEachBound(control, function(action, state) addButtons(action, buttons, state, id));
}
public function touchShit(control:Control, id)
{
forEachBound(control, function(action, state)
{
// action
});
}
/**
* Sets all actions that pertain to the binder to trigger when the supplied keys are used.
* If binder is a literal you can inline this

View file

@ -74,6 +74,16 @@ class GameOverSubstate extends MusicBeatSubstate
super.update(elapsed);
if (FlxG.onMobile)
{
var touch = FlxG.touches.getFirst();
if (touch != null)
{
if (touch.overlaps(bf))
endBullshit();
}
}
if (controls.ACCEPT)
{
endBullshit();

View file

@ -36,6 +36,7 @@ import flixel.util.FlxSort;
import flixel.util.FlxStringUtil;
import flixel.util.FlxTimer;
import haxe.Json;
import lime.ui.Haptic;
import lime.utils.Assets;
import openfl.Lib;
import openfl.display.BitmapData;
@ -2656,6 +2657,42 @@ class PlayState extends MusicBeatState
controls.NOTE_RIGHT_R
];
var widHalf = FlxG.width / 2;
var heightHalf = FlxG.height / 2;
if (FlxG.onMobile)
{
for (touch in FlxG.touches.list)
{
if (touch.justPressed)
{
if (touch.justPressedPosition.x >= widHalf)
{
if (touch.justPressedPosition.y >= heightHalf)
pressArray[3] = true;
else
pressArray[2] = true;
}
else if (touch.justPressedPosition.y >= heightHalf)
pressArray[1] = true;
else
pressArray[0] = true;
}
if (touch.justPressedPosition.x >= widHalf)
{
if (touch.justPressedPosition.y >= heightHalf)
holdArray[3] = true;
else
holdArray[2] = true;
}
else if (touch.justPressedPosition.y >= heightHalf)
holdArray[1] = true;
else
holdArray[0] = true;
}
}
// HOLDS, check for sustain notes
if (holdArray.contains(true) && /*!boyfriend.stunned && */ generatedMusic)
{
@ -2669,6 +2706,8 @@ class PlayState extends MusicBeatState
// PRESSES, check for note hits
if (pressArray.contains(true) && /*!boyfriend.stunned && */ generatedMusic)
{
Haptic.vibrate(400, 70);
boyfriend.holdTimer = 0;
var possibleNotes:Array<Note> = []; // notes that can be hit

View file

@ -24,6 +24,7 @@ import lime.graphics.Image;
import lime.media.AudioContext;
import lime.ui.Window;
import openfl.Assets;
import openfl.display.BitmapData;
import openfl.display.Sprite;
import openfl.events.AsyncErrorEvent;
import openfl.events.AsyncErrorEvent;
@ -80,6 +81,11 @@ class TitleState extends MusicBeatState
override public function create():Void
{
FlxG.debugger.addButton(LEFT, new BitmapData(200, 200), function()
{
FlxG.debugger.visible = false;
});
startedIntro = false;
FlxG.game.focusLostFramerate = 60;