Novice learning 'Starling' discussion

.
Hehe, it will turn black in “on update”, but it can be done correctly in “on complete”. How to stop “tween”
.
MyFilter. reset(); "is sufficient
.
This is the effect I want, by the way, are there any other ways to achieve it? Is there a simpler method, for example?
.
I found that the ‘value’ of the ‘tween complete trace’ change is correct, and it is estimated that the ‘myFilter. int’ method has produced a stacking effect.
.


.

I use the “ttf” font to display text, but when I enlarge the text box with “scale=6”, the text becomes blurry. Is there any way to solve this?

Have you tried initialising your textField at the larger size, then scaling down instead of scaling up?

.
It is possible to directly set the size of the text box without blurring.
.
This method is very concise, but unfortunately it doesn’t work in ‘starling’
Actuate.transform (img, 1).color (0xFF0000, 0.5);
.
If we support ‘starling’, that would be great
.
Actuate.transform (MySprite, 1).color (0xFF0000, 0.5);
.

What if the text box displays HTML formatted text and cannot be automatically resized according to the content? I don’t want to specify fixed width and height. TTF font.

You can extend the relevant display object class in Starling, to make this possible within your project, if it’s something you’re needing to do a lot.

For example, an extended Starling Sprite with added tintColor and tintStrength properties, that update a ColorMatrixFilter, would look like this:

import starling.display.Sprite;
import starling.filters.ColorMatrixFilter;

class TintableSprite extends Sprite {
    private var _tintStrength:Float = 0.0;
    private var _tintColor:Int = 0xFFFFFF;
    private var _colorMatrix:ColorMatrixFilter = new ColorMatrixFilter();

    public function new() {
        super();
        this.filter = _colorMatrix;
    }

    // Tint strength (0-1)
    public var tintStrength(get, set):Float;
    private function get_tintStrength():Float return _tintStrength;
    private function set_tintStrength(value:Float):Float {
        _tintStrength = value;
        updateTint();
        return value;
    }

    // Tint color (#RRGGBB)
    public var tintColor(get, set):Int;
    private function get_tintColor():Int return _tintColor;
    private function set_tintColor(value:Int):Int {
        _tintColor = value;
        updateTint();
        return value;
    }

    private function updateTint():Void {
        _colorMatrix.reset();
        if (_tintStrength > 0) _colorMatrix.tint(_tintColor, _tintStrength);
    }
}

Then, within a class that extends that TintableSprite, like a game asset, you can set the tint colour with the property tintColor (eg tintColor = 0xFF0000;) and its intensity with tintStrength (eg: tintStrength = 0.5;).

You can tween those properties like this:

Starling.current.juggler.tween(this, 2, {
    tintColor: 0xFF0000, // red
    tintStrength: 0.5,   // half tint
});
1 Like

.
Do you use ‘Asset Manager’ to load resources? Does’ Asset Manager ‘support in the’ html5 'project?
.
Is the last parameter ‘onProgress: Function’ a callback for the network loading progress of the resource file?

loadQueue(onComplete:Function, onError:Function = null, onProgress:Function = null):void”
.

.
I obtain sub textures (“SubTexture”) from the Texture Atlas and replace the texture (“Texture”) of the image (“Image”) to form an animation. Will this interrupt the “GPU” batch processing? thank you.
.

.
我从纹理图集(“TextureAtlas”)中获取子纹理(“SubTexture”)更换图像(“ Image”)的纹理(“Texture”)形成动画,这会打断“gpu”批处理么?谢谢。
.

.
How to dynamically modify ‘fps’?
.
How to dynamically modify the stage size? How to make the viewport follow the size changes of the stage? Used for screen adaptation.
.

How many people are using ‘Adobe Animate’? It’s not just me, is it?

What goals do people use ‘openfl’ to publish? HTML5 or Windows?

Yes I use it, within a helper class I use like a singleton, that I then reference from various parts of the application. As for HTML5, you’re still leveraging the OpenFL Assets class to reference the files actual, so nothing really changes except you’re passing them on to Starling’s Asset Manager. The reason I use it though is specifically for it’s spritesheet handling capabilities.

Here’s an example of how I use the Asset Manager to bring in a texture atlas:

import openfl.Assets;
import openfl.utils.ByteArray;
import starling.events.EventDispatcher;
import starling.textures.Texture;
import starling.textures.TextureAtlas;
import starling.utils.AssetManager;

/**
 * A helper for getting spritesheets into OpenFL, via the OpenFL Assets system and Starling AssetManager. 
 */
class SpriteSheets extends EventDispatcher {
	public static var assetManager:AssetManager;

	public function new() {
		super();
		if (assetManager == null) {
			assetManager = new AssetManager();
			assetManager.keepFontXmls = true;
		}
	}

	/**
	 * The texture and XML paths (as openfl.Assets would recognise it) are supplied as arguments.
	 * The resulting textures from the spritesheets are immediately available via SpriteSheets.getTexture(name).
	 * @param	texturePath as openfl.Assets would recognise it.
	 * @param	xmlPath as openfl.Assets would recognise it.
	 */
	public function addSpritesheet(texturePath:String, xmlPath:String):Void {
		assetManager.addTextureAtlas(texturePath, new TextureAtlas(Texture.fromData(Assets.getBytes(texturePath)), Xml.parse(Assets.getText(xmlPath))));
	}

	/**
	 * Access textures that were imported within a spritesheet.
	 * @param	name The name of the texture is it's original pre-spritesheet filename without the extension.
	 * @return A Starling Texture.
	 */
	public static function getTexture(name:String):Texture {
		var texture:Texture = assetManager.getTexture(name);
		if (texture != null) {
			return texture;
		} else {
			trace("SpriteSheets: Texture " + name + " not found in AssetManager.");
			return null;
		}
	}
}

I usually import all my sprite-sheets early in the app, pretty much at the entry point for Starling. Here’s an example of how I’d import 60 spritesheets sitting in the atf/dxt5/, leveraging that Spritesheets class I shared above. It will automatically load all found .atf files for sys targets (Hashlink, cpp, Neko, etc). For HTML (#else), I need to specify the number of spritesheets.

var spriteSheets:SpriteSheets = new SpriteSheets();

#if sys
for (i in 0...FileSystem.readDirectory("atf/dxt5/").length)
{
    spriteSheets.addSpritesheet("atf/dxt5/burst-" + i + ".atf", "xml/burst-" + i + ".xml");
}
#else
for (i in 0...60)
{
    spriteSheets.addSpritesheet("atf/dxt5/burst-" + i + ".atf", "xml/burst-" + i + ".xml");
}
#end

I used Adobe Flash extensively back in the day. I don’t use it anymore, but it’s not because I don’t appreciate what it can do, just the sort of work I do has changed. As far as vector drawing and animation goes, it was simple and powerful.

1 Like

Both? My current project is producing an OpenFL web-app (HTML5) that talks to an OpenFL+Starling content server (cpp/Windows), which issues commands to other devices on the network, including another OpenFL (cpp/Linux) content player.

I’m sorry I can’t answer all your questions. Some I don’t feel best qualified to answer, but I am also very busy with a tight deadline :sweat_smile:

1 Like

It is the total progress for all items in the queue. onProgress receives a value between 0.0 and 1.0.

Starling supports one texture in a batch. If other nearby parts of the display list are rendered using the same atlas, then they will be batched together with your animation. If they use different textures, then they will be in a different batch.

Changing from one SubTexture to another SubTexture from the same atlas will not affect batching.

The traditional OpenFL stage has a frameRate property that you can set. This will affect Starling’s frame rate too.

You can set the stageWidth and stageHeight properties of Starling’s stage. You can also set Starling’s viewPort property.

See Starling Manual: Multi-Resolution Development and Starling Manual: Device Rotation for details.

1 Like

Just a note for @785597448 though, I don’t believe this works for the HTML5 target. To maintain perceptual consistency with variable frame-rates, it’s usually advisable to reference delta time (time since last frame).

The Starling Juggler uses delta time internally to advance animations and tweens, but you can also reference it as a property of the Starling EnterFrameEvent.

addEventListener(EnterFrameEvent.ENTER_FRAME, tick);

private function tick(event:EnterFrameEvent):void
{
    var delta:Number = event.passedTime; // seconds since last frame
    // Use delta to update animations, movement, etc.
}
1 Like

.
Can ‘Starling’ obtain the ‘dpi’ of the current device?
.
The effect “window. vicePixelRatio” in “js”
.

You can access the equivalent of devicePixelRatio through the traditional OpenFL stage using stage.contentsScaleFactor or stage.window.scale.

You can get the actual DPI using Capabilities.screenDPI.

1 Like

.
I developed the “HTML5” game using “OpenFL” and “Starling”,
.
Can’t I directly load resources using the “Asset Manager” of “Starling”? But instead, use the “Assets” in “openfl” to load resources and manage them for the “Asset Manager”?
.
Asset Manager cannot directly load network resources?
.
Must the “Assets” of “openfl” be used to load network resources before they can be used by “Asset Manager”?
.

.
Does this mean that before using “Asset Manager”, network resource files must be loaded first before they can be used by “Asset Manager”? Is that so?
.
Use “Assets” in “openfl” to load resources, or use “Loader URLLoader” to load resources, and then give the loaded resources to “Asset Manager” for management and use?
.
Instead of directly using “Asset Manager” to load network resource files?
.