Skip to content

Commit

Permalink
finally fixed the positioning and scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
nebulazorua committed Jun 23, 2023
1 parent 002782c commit 89516c1
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions source/gameObjects/userInterface/UnownSubstate.hx
Original file line number Diff line number Diff line change
Expand Up @@ -121,37 +121,48 @@ class UnownSubstate extends MusicBeatSubState
add(unowns);

var realThing:Int = 0;
var scale:Float = 1;
var width:Float = 100 * (selectedWord.length-1);
if(width > FlxG.width)
scale *= FlxG.width / width;
width *= scale;

for (i in 0...selectedWord.length) {
if (!selectedWord.isSpace(i))
{
var unown:FlxSprite = new FlxSprite(0, 90);
//unown.x += 350 - (35 * selectedWord.length);
//var thing = 1 - (0.05 * selectedWord.length);
if (260 - (15 * selectedWord.length) <= 0)
unown.x += 40 * i;
else
unown.x += (260 - (15 * selectedWord.length)) * i;
var realScale = 1 - (0.05 * selectedWord.length);
if (realScale < 0.2)
realScale = 0.2;
unown.scale.set(realScale, realScale);
unown.updateHitbox();
var xPos = i * 100;
unown.x = xPos;
unown.scale.set(0.5, 0.5);
unown.frames = Paths.getSparrowAtlas('UI/base/Unown_Alphabet');
unown.animation.addByPrefix('idle', selectedWord.charAt(i), 24, true);
unown.animation.play('idle');
unowns.add(unown);

var line:FlxSprite = new FlxSprite(unown.x, unown.y).loadGraphic(Paths.image('UI/base/line'));
line.y += 500;
line.scale.set(unown.scale.x, unown.scale.y);
line.updateHitbox();
line.ID = realThing;
lines.add(line);
realThing++;
}
}

for (i in 0...unowns.members.length){
var u:FlxSprite = unowns.members[i];
var l:FlxSprite = lines.members[i];

u.scale.scale(scale);
u.updateHitbox();
u.x *= scale;
//u.x += (FlxG.width - width)/2;
l.x = u.x;
l.scale.copyFrom(u.scale);
l.updateHitbox();
}

unowns.screenCenter(X);
unowns.y += 100;
for (i in 0...lines.length) {
lines.members[i].x = unowns.members[i].x;
}
Expand Down

0 comments on commit 89516c1

Please sign in to comment.