I'm finally taking the time to go from Actionscript 2.0 to Actionscript 3.0, and I'm trying to figure out how to pull off a simple depthing system I had at my disposal in 2 that doesn't seem to be possible in 3.
The code goes something like this:
onClipEvent(enterFrame){
this.swapDepths(1000+Math.ceil(this._y));
}
This way, I could easily get mock 3D effects as something moves up and down on the screen.
Also understand, this is a really basic application of the idea. Usually I'd put in logic to allow multiple movieclips to exist at one Y value.
Whatever the case, with the changes to AS's depthing, this method is no longer possible in this state. Maybe I just have an incomplete knowledge of how the new system works, I am just a hobbyist AS programmer, but is there a better/simpler/more elegant way to pull this off in AS3.0, short of keeping track of every clip/sprite on the stage?
I'm using Adobe Flash CS4 professional, if that makes any difference. Additionally, this isn't of much importance, yet. I'm still getting my bearings, but I came across the depthing changes during a quick project a few weeks ago when learning about adding Child MovieClips, and it seemed like I could only easily add things to the front or back of the stage, not inbetween.
The main difference between AS 2.0 and AS 3.0 is the depth management. In AS 2.0 you could use any depth you wanted. However, with AS 3.0 you can not (leave any depth unused/empty).
There are still several methods that allow you to change depth, swap depths etc. so you are free to use those.
Related
I'm developing a game based on the libGDX framework in eclipse that will have smoothly movements between my entities, so for that, I have used TweenEngine (and it is working nice), but recently I found that libGDX have its own class for interpolations.
I know both are for tweening (or for nice and smoothly animations), and I just want to know if there are technical difference or limitations between this 2 options basically because if both are the same, I would opt for the second one since it is already inside libGDX.
From one side there's generally better to use included tools because of integration and final application size (not saying of setting up the environment or exporting project problems).
On the other hand please notice that Libgdx Interpolation starts to be useful only when you are using it with Scene2D actions. And here is the problem in my opinion because you must implement stage and actors mechanisms - which is good idea by itelf but can be almost impossible if you have created almost whole application without it.
Then I would recommend you:
choose Scene2D actions + Interpolation easing if you are able to implement Scene2D in your project and the easing actions are only reason you want to use Tween Engine
choose Universal Tween Engine if you want to stay independent of new machanisms and use Sprites etc in traditional way
I have for a really long time been searching for a tutorial for an augmented reality application where the users can rotate and\or move a rendered 3D object with hand movements. I have found a few example applications of this, but none with viewable sourcecode, or in any way allowing me to change the models loaded.
What I need is either a working application that I can tamper with in AS3, or a decent tutorial for creating this kind of motion tracking. (I have been able to create a motion tracking application in itself, but not as an AR application where the models loaded are the ones affected by my movement.)
I am rather new to augmented reality programming, and only have the basics of marker based AR down, but I really don't need anything fancy, nor do I particularly need to understand the cone 100% (though obviously it would be better if I did). I just need it to work.
What you need is FLAR toolkit.
http://www.libspark.org/wiki/saqoosha/FLARToolKit/en
Here's a tutorial: http://mlab.taik.fi/mediacode/archives/1939
Enjoy
Novice programmer here.
I'm currently coding a simple game with the title screen and the main game loop in separate "keyframes" (this is in CS6). Once I transition from the title screen to the game keyframe I'm concerned that the buttons/movieclips/variables are going to stick around and waste memory + clutter the screen.
If I have the variables/functions set to "private" will that help the garbage collector take care of them? How should I go about "clearing the screen" and making sure I'm not being wasteful/leaking memory?
None of the tutorials or books I've been reading to learn AS3 have really covered this topic, if there are any good guides or obvious tips I've missed as far as memory management best practice goes in AS3 I'm interested in seeing them. The only thing I've learned so far is that I should manually set all my event listeners to weak reference.
Bonus question: I'm using a full-screen bitmap and blitting things onto it for my display. If I am blitting dozens of objects onto the screen per frame I don't need to worry about the blitted "sprites" that are being "covered up," do I? I'm hoping that the bitmap is one pixel thick and not just stacking things on top of each other.
Firstly, the only way you will have total control over your resources is if you leave the timeline for what it was intended for, creating and exporting assets in to swc or swf format, which you can embed the former and either embed or load the latter.
What you should be doing is learning how to develop in an Object Oriented manner, starting with a Document class (as you're using CS6) and then building your game using a series of classes which have defined tasks. Using classes promotes re-usability throughout your game. Depending on the complexity, I would consider a framework like PureMVC or Robot legs.
Garbage collection in flash is mark and sweep, which means you have to de-reference all your objects, which usually starts with removing associated listeners, timers and any further references to them, eg. clearing from arrays or objects hashes. Finally you would set the object in question to null which makes it 'elligible' for garbage collection but does not actually guarantee it. Flash will come and clean up as it sees fit.
Personally if you could get hold of Flash Builder, this has a fantastic memory management profiling tool, when you are developing using OOP mentioned above, you can use this tool to see all the instances that exist in your game. Now the good part here is you can do a memory snapshots in time, and compare them to see which objects linger around and are causing memory leaks. There is a garbage collection button which you should invoke between capturing snapshots, this is only available as you are developing, though using Adobe AIR you can force gc calls manually.
Regarding your bonus question, im not sure how you are doing this blitting, if you are adding objects to the stage this is increasing memory, you cannot avoid this. What you describe as 1px thick is what flash renders, you can see what is being redrawn by right clicking on the stage and selecting the redraw regions option, to see a red box showing what flash has to redraw, it will only redraw what it needs to, this is useful to check if your frame rate suffers.
So to summarize:
Consider using Flash CS6 for creating assets.
Learn about Object Oriented programming in Actionscript 3.
Consider developing in Flash Builder (or free Flash Develop).
OOP will help with organisation and de-referencing objects for garbage collection.
I hope this helps and good luck with your game.
paper.js
EaselJS
fabric.js
KineticJS
Hello guys I am new in html5 canvas development and I am lost in choosing canvas frameworks. There are so many of them that I can't find out what to use. So here I am! I want your help to choose which one is better for my needs. There are my needs
1) I want the framework used Vector graphics, I know canvas is not DOM, I realy don't care about it but what I mean is I want to manipulate with objects after its creation, PaperJS has this feature I don't know about others. If advanced mouse events will be available it would be better.
2) I want to use the framework for images, I will load image and animate them with canvas, move, animate some colors...
3) I want the framework to be fast because of my needs (image animation should be smooth)
4) I want the framework to have good community because I know I will need some help.
So what do you think which one is better for me? and please if you can write down from my list which are the strength and weakness for each framework?
HTML5 canvas is still very fresh environment. You can get impression there is a lot of tools already available, they are often quite immature though.
My answer will cover only part of your question because I used only KineticJS and EaselJS.
You can start from reading opinions at this page (mine is the last one at the bottom).
Speaking shortly KineticJS has lower entry barrier. It's simple drawing library and has some support for mouse events too. At the time I was trying to use it it was barely extendable. I found it really hard to customize for my needs.
EaselJS is a bit harder to start with, but it's more advanced too. Now it's part of other libs set known all together as CreateJS. It seems that lot of development going around there.
Both Kinetic and Easel supports mouse event. I don't remember
well the Kinetic, sensing 'onMouseOver' is costy with Easel though.
Also both mentioned libs allows objects manipulation. You can find
here TweenJS also useful as addition.
Again both Kinetic and Easel allows this. Easel also has support for
sprites - 'animated images' well known for web game developers.
I'm not sure about Kinetic as I haven't reached animation part of my
project before I dropped it (the lib, not the project). With Easel
speed is tricky. It has some optimization methods implemented like
for example objects cache or snapToPixel flag. Examples seems to run
really well. However for my project using Easel smoothness still is
an issue despite quite a lot of effort put in optimization. Maybe I
misused the API or there is still place for more optimalization I
haven't noticed.
Both libs are quite young but seems to be actively developed.
Authors are rather responsive. Community still isn't big, but I
guess CreateJS as more complete set of tools for creating games will
grow faster.
If you want to check here is the project I mentioned. It's a web page made with usage of EaselJS + TweenJS. Still needs some minor tweaking though.
I've been working with several different programming languages recently, and I've come to the conclusion that I don't really like the display list in Actionscript. I would much rather have an update/draw loop and draw and manage everything manually like in XNA (C#).
What I do like in actionscript is the ease of use of events, movieclips animations and vector graphics.
What are the possibillites for this?
I would really like to be able to use animated movieclips, but I think that would be impossible without the display list, so I could settle with writing my own animation system with spritesheets.
Rewriting the entire event system isn't something I look forward to though.
Are there any (molehill) frameworks that work without the display list?
You can do something similar by creating a Bitmap with the same size as the stage, attaching it to the stage as a child and using it like a "screen", by blitting your graphics on it every frame (on ENTER_FRAME event). I think it's even mentioned somewhere in the official Adobe documentation, as a method of efficiently animating a large number of objects.
I would advise you to muster up the courage and let go of C# when programming in ActionScript. As Bjarne Stroustrup wisely said in his book The C++ Programming Language:
...applying techniques effective in one language to another typically
leads to awkward, poorly performing, and hard-to-maintain code. Such
code is also most frustrating to write because every line of code and
every compiler error message reminds the programmer that the language
used differs from 'the old language.' You can write in the style of
[another language], but doing so is neither pleasant nor economical in a language
with a different philosophy.
I think that applies very well to the question you're asking here.