Hi, I’ve got problem that couldn’t solve for a long time. When I build this code on ios-device my FPS rapidly going down(like from 30 to 14). If I’m right the same code worked perfect few month ago. Any sugestion? Help please:)
Every second I do ‘afterTimer’ - function. This is the reason but why and how solve it I don’t know.
I just move 100 sprites. Or may be you know how to do it better. Thx.
package ui;
import openfl.Assets;
import openfl.display.Bitmap;
import matreshka.main.Game;
class Snow extends ChildOnTheStage
{
private var game:Game;
private var snowBit1 = Assets.getBitmapData("assets/img/Snow1.png");
private var snowBit2 = Assets.getBitmapData("assets/img/Snow2.png");
private var snowBit3 = Assets.getBitmapData("assets/img/Snow3.png");
private var snowBit4 = Assets.getBitmapData("assets/img/Snow4.png");
private var snowBit5 = Assets.getBitmapData("assets/img/Snow5.png");
public function new(game:Game) {
super(game);
this.game = game;
trace('put snow');
for (i in 0...100) {
addSnow(Std.random(4)+1);
}
canBeStopped = false;
onMove = true;
nominalSpeed = 10;
afterTimer = function() {
for ( z in 0...this.numChildren) {
var i = this.getChildAt(z);
i.x = i.x - nominalSpeed;
i.y = i.y + nominalSpeed;
if (i.x < -i.width) {
i.x = game.screenW;
}
if (i.y > game.uiRect.height) {
i.y = -i.height;
}
}
};
}
private function addSnow(i:Int) {
var snowBit:Bitmap = null;
switch i {
case 1 :
snowBit = new Bitmap(snowBit1);
case 2 :
snowBit = new Bitmap(snowBit2);
case 3 :
snowBit = new Bitmap(snowBit3);
case 4 :
snowBit = new Bitmap(snowBit4);
default :
snowBit = new Bitmap(snowBit5);
}
var randomX = Std.random(Std.int(game.screenW));
var randomY = Std.random(Std.int(game.screenH));
snowBit.x = randomX;
snowBit.y = randomY;
addChild(snowBit);
}
}
haxelib list:
actuate: 1.6.3 1.7.2 1.7.5 1.8.1 1.8.2 1.8.3 [1.8.6] extension-admob: 1.4.6 [1.4.7] extension-android-support-v4: [1.0.0] extension-gamecenter: [1.2.0] extension-googleplayservices-lib: [1.1.0] extension-iap: [1.2.0] extension-share: 1.2.2 2.2.0 [2.2.1] gamecenter: 1.0.1 1.1.0 [1.1.1] hscript: 2.0.4 [2.0.5] hxcpp: 3.1.39 3.1.68 3.2.180 [3.2.193] 3.2.37 iap: 1.0.4 [1.0.6] lime-tools: 1.4.0 1.5.6 [1.5.7] lime: 0.9.7 1.0.0 1.0.1 2.0.0 2.0.0-alpha.7 2.0.1 2.0.6 2.1.1 2.2.1 2.6.5 2.6.8 [2.7.0] openfl-admob: 1.3.2 1.3.4 1.4.0 [1.4.2] openfl-gps-lib: 1.0.2 [1.4.3] openfl-native: [1.4.0] openfl-share: 1.2.0 [1.2.2] openfl-tools: [1.0.10] openfl: 1.4.0 2.0.0 2.0.1 2.1.5 2.1.6 2.1.7 2.2.4 2.2.6 3.3.6 3.3.8 [3.4.0] random: 1.4.0 [1.4.1] spritesheet: [1.2.0] stablexui: [1.0.9] 1.1.1 1.1.4 1.1.5