|
Viewing 1 to (29 Total) |
|
Thanks Hugh, I did some benchmarks, here the results:
(tested on a Samsung galaxy 5500, on Android, with 1000 rotating triangles)
A) Drawing each triangle inside a sprite, then rotate the sprite with Sprite.rotation. I got 11 fps.
B) Drawing each triangle inside a sprite, then rotate the sprite by multiplying each one of its points by a rotation matrix and redraw the triangle. 11 fps too.
C) Drawing all triangles on a single sprite, then rotate the sprite by multiplying each one of its points by a rotation matrix and redraw the triangle. Absolutly smooth, but I see things like more than 100 fps, I dont know why such an high framerate since I limited it to 45 fps...
I attached the source code of the project, if someone modify it please post the new version. Im interested in other's people results too.
Posted on June 01, 2012 at 5:08 PM
|
|
(I post it here too so it haves more visibility, the original is on the NME mailing list)
Im using drawTriangles and (begin/end)fill to programmatically draw grass. Each grass is composed of 3 or 4 sprites, each sprite contains 2 triangles (1 triangle in the case of the end of a grass). Then the grass is animated using rotations of the sprites.
This works perfect when running on a mac, but on Android phone this method seems to slow when animating 50 grass instances.
My question is, if I want to do this programmatically (each grass can be affected, for example, by wind) ¿Im doing it the right way? How performance of graphics.beginFill -> drawTriangles/drawRect/draw* -> endFill compares to graphics.drawTiles?
If I draw all the triangles inside one single sprite, is it faster than drawing 2 triangles per sprite? And if I want a triangle rotation, is faster to rotate the sprite wich contains it, or its better to redraw the triangles with new points calculated using rotation matrix multiplication? How NME internally handles the rotation of a sprite containing a triangle vs rotation of a sprite containing a bitmap?
Im sorry for such a bunch of questions, any information is appreciated. Benchmarks results would be useful, but im interested on internal details too.
I think this is an interesting topic for anyone using graphics primitives to draw things, so it would be nice to document it here.
Posted on May 29, 2012 at 2:54 PM
|
|
No, im using mp3 for music and sound on Flash, and wav for sound and mp3 for music on Android.
Stop and control of volume/pan works on flash, but not on Android. I haven't tested other platforms.
Posted on November 16, 2011 at 2:02 PM
|
|
I ended doing this workarround: Since nme on android can only play one mp3 at a time, I used mp3 format for music, and stop it by playing a very short and quiet mp3 file.
That worked Ok for me.
Posted on November 15, 2011 at 8:25 PM
|
|
Im having problems with this code on Android:
var sound_name = "Data/Party_Gu-Jeremy_S-8250_hifi.mp3";
var sound:Sound = ApplicationMain.getAsset(sound_name);
var channel = sound.play(0,-1);
channel.stop();
The music starts playing ok, but i cant stop it. Also, in flash this should start looping again and again, but instead only plays it one single time.
Someone have experienced this issue?
Posted on October 31, 2011 at 1:55 PM
|
|
That was fast! 
Posted on October 12, 2011 at 5:24 PM
|
|
Finally I solved it! To make this work with gm2d, you need to put "Game.mapEscapeToBack = false;" somewhere in your code, now it works.
Thanks!
Posted on October 06, 2011 at 11:28 AM
|
|
I think this problem is related to the fact im using gm2d, the stopPropagation method works ok with simple nme-only tests.
Still investigating this.
Posted on October 06, 2011 at 10:40 AM
|
|
Now I do:
Lib.current.stage.addEventListener(Event.ACTIVATE, function(_) { reload(); } );
And on reload function I reload all my sounds, everything works OK now.
Posted on October 05, 2011 at 10:41 AM
|
|
I fixed the multimedia sound key thing, i was always returning "true" on the keydown and keyup events from the java side while trying to ignore Android back button.
Now the only problem is sound doesnt work when I resume activity.
Posted on October 05, 2011 at 8:23 AM
|
|
Not working for me, i did:
Lib.current.stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDownStageEvent);
Lib.current.stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUpStageEvent);
and:
public function onKeyDownStageEvent(event:KeyboardEvent):Void
{
trace("Keydown: " + event.keyCode);
event.stopImmediatePropagation();
event.stopPropagation();
}
public function onKeyUpStageEvent(event:KeyboardEvent):Void
{
trace("Keyup: " + event.keyCode);
event.stopImmediatePropagation();
event.stopPropagation();
}
On Android log I see:
E/NME ( 1608): OnKey 27 1
I/trace ( 1608): RanitasScene.hx:250: Keydown: 27
I/ActivityManager( 115): Pause activity: com.example.myapp/.MainActivity
I/NME ( 1608): Activity action 2
I/ActivityManager( 1608): onPause called: com.example.myapp.MainActivity
And the application gets minimized.
Posted on October 05, 2011 at 8:07 AM
|
|
I get this:
dan@dan-desktop:~/haxe/workspace/ranitas$ haxelib run nme build ranitas.nmml android
./RanitasScene.hx:268: characters 3-23 : nme.events.KeyboardEvent has no field preventDefault
./RanitasScene.hx:278: characters 3-23 : nme.events.KeyboardEvent has no field preventDefault
And I cant find any reference to preventDefault on svn repository.
Posted on October 04, 2011 at 4:01 PM
|
|
Has anyone have any succes overriding Android back button default behavior of "minimizing" the application?
Im triying to be able to catch back button and display a menu without the application going background.
How would you do it?
Posted on October 04, 2011 at 2:02 PM
|
|
My nmml file ended like this:
<assets path="assets" include="*.png" />
<assets path="assets" include="*.json" />
<assets path="assets" include="*.ttf" />
<assets path="assets" include="*.ogg" /
Otherwise it doesnt works. Now sound works when applicantion starts, but if I stop it and then resumen it doesnt works. Multimedia application keys doesnt works again.
Posted on October 04, 2011 at 1:35 PM
|
|
Maybe my nmml file is incorrect? this is the assets part:
<assets>
<text name="assets/texture.json" />
<font name="assets/Sansation_Bold.ttf" />
<font name="assets/Sansation_Regular.ttf" />
<sound name="assets/drum.ogg" id="drum" />
<sound name="assets/bass.ogg" id="bass" />
</assets>
<assets path="assets" include="*.png" />
Is something wrong there?
Posted on October 03, 2011 at 3:54 PM
|
|
It worked, thanks!
Posted on October 03, 2011 at 3:21 PM
|
|
I modifified SoundManager so now, it simply do:
public static function play( str : String ) : Void
{
if (soundState<NO_SOUND )
{
var sound : Sound = nme.Assets.getSound(str);
sound.play();
}
}
Works with bass.ogg but it still crashes with drum.ogg.
Posted on October 03, 2011 at 2:04 PM
|
|
Im doing:
var format = new TextFormat("assets/Sansation_Regular", 48, 0x000000);
format.align = TextFormatAlign.CENTER;
var textField = new TextField();
textField.defaultTextFormat = format;
will try your suggestion
Posted on October 03, 2011 at 1:58 PM
|
|
Sound doesnt work after sleeping, but multimedia volume keys works now. The only ogg i found working is "bass.ogg" from nme sample 6.
What is strange is that nme sample 6 works perfectly now.
Posted on October 03, 2011 at 1:40 PM
|
|
Nme doesnt find my ttf files on Android if I dont do this:
mkdir bin/android/bin/assets/assets
cp bin/android/bin/assets/assets_sansation_bold_ttf bin/android/bin/assets/assets/Sansation_Bold
cp bin/android/bin/assets/assets_sansation_regular_ttf bin/android/bin/assets/assets/Sansation_Regular
I found these paths by looking at Android log.
Posted on October 03, 2011 at 1:37 PM
|