How to fadeOut splash screen after a couple seconds? - format

I have the following splash screen:
final boundingBox = new FlxSprite();
boundingBox.makeGraphic(300, 200, 0xff428BBF);
boundingBox.screenCenter(XY);
add(boundingBox);
final level_1_text = new FlxText(0, 0, 0, "LEVEL 1", 36);
level_1_text.screenCenter(XY);
add(level_1_text);
It's currently in a SubState, and I'm opening it in my Level1 update function. What I want is for the screen to Fade Out after a few seconds, but still have game functionality.
Is it better to just create the splash screen in the Level itself? To just create a function?
I couldn't find any documentation on how to fade out text. How can I fade it out after 5 seocnds?

To fade out the text you can use FlxTween.
FlxTween.tween(textObject, {alpha: 0}, seconds);
OR you can use FlxSpriteUtil
FlxSpriteUtil.fadeOut(textObject, seconds).

Related

Animate a property back and forth (without jumping to the end)

I am using the following code to "zoom" a page in and out.
const doEffect = args => {
const screen = args.object.page.getViewById('mainScreen')
screen.animate({
scale: {
x: isSettingsShown ? 1 : .75,
y: isSettingsShown ? 1 : .75
},
duration: 2000
})
isSettingsShown = !isSettingsShown
}
There is a toggle button on the page that updates the isSettingsShown variable. However when I toggle the var before the animation has ended, it "jumps" to the end of the animation. Can I prevent this from happening? I would like to start the animation from the last position it was at.
Pausing the animation or retaining the state of animation is still an open feature request at the moment.
You may still be able to do this natively by operating on the nativeView's CALayer (iOS) / Animator (Android).

How to redraw canvas with a new image via ctx.clearRect(0,0,canvas.width,canvas.height) script action?

I am trying to refresh canvas image coming as video frame usbcam input every 5 sec
Since redraw fails I was told to clear image/canvas first
Nice example on how to
HTML5 Clear Canvas Tutorial
file:///D:/firefox%20pobrane/HTML5%20Canvas%20Clear%20Canvas%20Tutorial.htm
context.clearRect(0, 0, canvas.width, canvas.height);
should work as suggested
but I don't get canvas cleared if I insert
context.stroke();
context.clearRect(0, 0, canvas.width, canvas.height);
directly
Canvas clear works for me as button click event only
Any idea how to modify the above example to have canvas cleared by script code only (timeOut .. 5000) ?
Another example
file:///D:/firefox%20pobrane/javascript%20-%20How%20to%20clear%20the%20canvas%20for%20redrawing%20-%20Stack%20Overflow.htm

JavaFX: Navigating through a Canvas within a ScrollPane of equal dimensions

I created a 10 000 x 10 000 pixel canvas, placed it inside a scroll pane with dimensions 300 x 300. This was implemented fine. The whole grid was drawn and I could scroll through it.
I'm tasked to instead create the same functionality, except with a 300 x 300 canvas instead. As speed is important in this program, I'm told this would work much faster.
My problem is that when I do this, I lose access to the scroll bars on the bottom and right of the scroll pane. How do I regain access to those scroll bars, to physically scroll?
The canvas is updating at 60 steps per second. What's being drawn is a square grid from the information in a 2D array.
Since the the viewport handling will be done by the drawing logic, it's rather easy to create a "ScrollPane" yourself using a GridPane:
public static ScrollBar createScrollBar(Orientation orientation, double fullSize, double canvasSize) {
ScrollBar sb = new ScrollBar();
sb.setOrientation(orientation);
sb.setMax(fullSize - canvasSize);
sb.setVisibleAmount(canvasSize);
return sb;
}
Canvas canvas = new Canvas();
canvas.setHeight(300);
canvas.setWidth(300);
ScrollBar vScroll = createScrollBar(Orientation.VERTICAL, 10000, 300);
ScrollBar hScroll = createScrollBar(Orientation.HORIZONTAL, 10000, 300);
GridPane scrollPane = new GridPane();
scrollPane.addColumn(0, canvas, hScroll);
scrollPane.add(vScroll, 1, 0);

Clearing the drawn SpriteFont in XNA 4.0

This code is used to basically display number of times the user touches the screen. But the problem is every time the Update method(XNA 4.0), the previous texture is Drawn upon , therefore the count cannot be read. How do i clear the SpriteFont texture each time when it is redrawn?.
//Code used to draw the Sprite Font.!
batch.DrawString(fontSegoe, "Touches "+count, new Vector2(100, 100), Color.Black, 0, Vector2.Zero, 1, SpriteEffects.None, 0f);
Make sure to clear the screen at the beginning of Draw()
GraphicsDevice.Clear(Color.Black); //Use any color of your choice

Scrolling Background

I'm trying out new things for a simple game in Portrait mode, I want to add a seamless scrolling background to a game, the image is 512x512px.
The Main scrolling I want to have is Vertically, but I want to be able to scroll sideways too within the bounds of the image size. How should I go about with this, I'm using cocos2d.
David
Try repeating the texture (in this case within 2000px)
CGRect repeatRect = CGRectMake(0, 0, 2000, 2000);
CCSprite *background = [CCSprite spriteWithFile:#"Background.png" rect:repeatRect];
ccTexParams params =
{
GL_NEAREST,
GL_NEAREST_MIPMAP_LINEAR,
GL_REPEAT,
GL_REPEAT
};
[background.texture setTexParameters:&params];

Resources