camera zoom fixes for mobile

This commit is contained in:
Cameron Taylor 2021-08-21 20:45:03 -04:00
parent d25b81e1dc
commit 1992d5363e
2 changed files with 52 additions and 33 deletions

View file

@ -1,6 +1,8 @@
package;
import flash.text.TextField;
import flixel.FlxCamera;
import flixel.FlxGame;
import flixel.FlxSprite;
import flixel.FlxState;
import flixel.addons.display.FlxGridOverlay;
@ -99,7 +101,13 @@ class FreeplayState extends MusicBeatState
// LOAD CHARACTERS
bg = new FlxSprite().loadGraphic(Paths.image('menuDesat'));
bg.setGraphicSize(Std.int(FlxG.width / FlxG.camera.initialZoom));
bg.setGraphicSize(Std.int(FlxG.width));
bg.updateHitbox();
trace(FlxG.width);
trace(FlxG.camera.zoom);
trace(FlxG.camera.initialZoom);
trace(FlxCamera.defaultZoom);
trace(FlxG.initialZoom);
add(bg);
grpSongs = new FlxTypedGroup<Alphabet>();
@ -197,13 +205,39 @@ class FreeplayState extends MusicBeatState
var velTouch:Float = 0;
var veloctiyLoopShit:Float = 0;
var touchTimer:Float = 0;
override function update(elapsed:Float)
{
super.update(elapsed);
if (FlxG.sound.music != null)
{
if (FlxG.sound.music.volume < 0.7)
{
FlxG.sound.music.volume += 0.5 * FlxG.elapsed;
}
}
lerpScore = CoolUtil.coolLerp(lerpScore, intendedScore, 0.4);
bg.color = FlxColor.interpolate(bg.color, coolColors[songs[curSelected].week % coolColors.length], CoolUtil.camLerpShit(0.045));
scoreText.text = "PERSONAL BEST:" + Math.round(lerpScore);
positionHighscore();
var upP = controls.UI_UP_P;
var downP = controls.UI_DOWN_P;
var accepted = controls.ACCEPT;
if (FlxG.onMobile)
{
if (FlxG.touches.getFirst() != null)
{
if (touchTimer >= 1.5)
accepted = true;
touchTimer += FlxG.elapsed;
var touch:FlxTouch = FlxG.touches.getFirst();
velTouch = Math.abs((touch.screenY - dyTouch)) / 50;
@ -228,6 +262,8 @@ class FreeplayState extends MusicBeatState
}
else
{
touchTimer = 0;
if (velTouch >= 0)
{
trace(velTouch);
@ -248,27 +284,6 @@ class FreeplayState extends MusicBeatState
}
}
super.update(elapsed);
if (FlxG.sound.music != null)
{
if (FlxG.sound.music.volume < 0.7)
{
FlxG.sound.music.volume += 0.5 * FlxG.elapsed;
}
}
lerpScore = CoolUtil.coolLerp(lerpScore, intendedScore, 0.4);
bg.color = FlxColor.interpolate(bg.color, coolColors[songs[curSelected].week % coolColors.length], CoolUtil.camLerpShit(0.045));
scoreText.text = "PERSONAL BEST:" + Math.round(lerpScore);
positionHighscore();
var upP = controls.UI_UP_P;
var downP = controls.UI_DOWN_P;
var accepted = controls.ACCEPT;
#if mobile
for (touch in FlxG.touches.list)
{

View file

@ -164,6 +164,10 @@ class PlayState extends MusicBeatState
override public function create()
{
defaultCamZoom = FlxCamera.defaultZoom;
defaultCamZoom *= 1.05;
if (FlxG.sound.music != null)
FlxG.sound.music.stop();
@ -282,7 +286,7 @@ class PlayState extends MusicBeatState
add(street);
case "milf" | 'satin-panties' | 'high':
curStage = 'limo';
defaultCamZoom = 0.90;
defaultCamZoom *= 0.90;
var skyBG:FlxSprite = new FlxSprite(-120, -50).loadGraphic(Paths.image('limo/limoSunset'));
skyBG.scrollFactor.set(0.1, 0.1);
@ -323,7 +327,7 @@ class PlayState extends MusicBeatState
case "cocoa" | 'eggnog':
curStage = 'mall';
defaultCamZoom = 0.80;
defaultCamZoom *= 0.80;
var bg:FlxSprite = new FlxSprite(-1000, -500).loadGraphic(Paths.image('christmas/bgWalls'));
bg.antialiasing = true;
@ -395,7 +399,7 @@ class PlayState extends MusicBeatState
case 'senpai' | 'roses':
curStage = 'school';
// defaultCamZoom = 0.9;
// defaultCamZoom *= 0.9;
var bgSky = new FlxSprite().loadGraphic(Paths.image('weeb/weebSky'));
bgSky.scrollFactor.set(0.1, 0.1);
@ -519,7 +523,7 @@ class PlayState extends MusicBeatState
*/
case 'guns' | 'stress' | 'ugh':
defaultCamZoom = 0.90;
defaultCamZoom *= 0.90;
curStage = 'tank';
var bg:BGSprite = new BGSprite('tankSky', -400, -400, 0, 0);
@ -592,7 +596,7 @@ class PlayState extends MusicBeatState
foregroundSprites.add(fgTank3);
default:
defaultCamZoom = 0.9;
defaultCamZoom *= 0.9;
curStage = 'stage';
var bg:BGSprite = new BGSprite('stageback', -600, -200, 0.9, 0.9);
@ -1776,7 +1780,7 @@ class PlayState extends MusicBeatState
function tweenCamIn():Void
{
FlxTween.tween(FlxG.camera, {zoom: 1.3}, (Conductor.stepCrochet * 4 / 1000), {ease: FlxEase.elasticInOut});
FlxTween.tween(FlxG.camera, {zoom: 1.3 * FlxCamera.defaultZoom}, (Conductor.stepCrochet * 4 / 1000), {ease: FlxEase.elasticInOut});
}
override function openSubState(SubState:FlxSubState)
@ -2031,7 +2035,7 @@ class PlayState extends MusicBeatState
if (camZooming)
{
FlxG.camera.zoom = FlxMath.lerp(defaultCamZoom, FlxG.camera.zoom, 0.95);
camHUD.zoom = FlxMath.lerp(1, camHUD.zoom, 0.95);
camHUD.zoom = FlxMath.lerp(1 * FlxCamera.defaultZoom, camHUD.zoom, 0.95);
}
FlxG.watch.addQuick("beatShit", curBeat);
@ -2631,7 +2635,7 @@ class PlayState extends MusicBeatState
}
if (SONG.song.toLowerCase() == 'tutorial')
FlxTween.tween(FlxG.camera, {zoom: 1}, (Conductor.stepCrochet * 4 / 1000), {ease: FlxEase.elasticInOut});
FlxTween.tween(FlxG.camera, {zoom: 1 * FlxCamera.defaultZoom}, (Conductor.stepCrochet * 4 / 1000), {ease: FlxEase.elasticInOut});
}
}
@ -3020,13 +3024,13 @@ class PlayState extends MusicBeatState
{
if (curSong.toLowerCase() == 'milf' && curBeat >= 168 && curBeat < 200 && camZooming && FlxG.camera.zoom < 1.35)
{
FlxG.camera.zoom += 0.015;
FlxG.camera.zoom += 0.015 * FlxCamera.defaultZoom;
camHUD.zoom += 0.03;
}
if (camZooming && FlxG.camera.zoom < 1.35 && curBeat % 4 == 0)
if (camZooming && FlxG.camera.zoom < (1.35 * FlxCamera.defaultZoom) && curBeat % 4 == 0)
{
FlxG.camera.zoom += 0.015;
FlxG.camera.zoom += 0.015 * FlxCamera.defaultZoom;
camHUD.zoom += 0.03;
}
}