I'm trying to create a complex parallax effect in Flash video sequence that includes translation and scaling among many layers.
I've been looking for a way to set up my scene to where I could just animate one object (preferably with motion tween) and then apply some percentage of that animation to each background object (or flip values accordingly).
Is there any way to harvest Motion Tween data out of a layer of a MovieClip and translate that into x,y values for objects? [So far I've only created instances of objects and set their positions through actionscript.]
Seems like you need to use a copy motion option of the layer context menu
Also tweening actionscript libraries e.g. TweenMax are capable of tweening any properties of any objects, but they do it with actionscript (which can be easily copied/modified/pasted), not Adobe Flash UI.
So converting every visual element to a movieclip allowed me to position the items in Z as well. That pretty much solved my problem.
Thanks everyone.
In my game I have some gold that the player can collect. My problem is I want to individually refernce textures of gold so i can take that particular instance of gold off the screen (player picked it up). How would I go about doing this as i am pretty sure you cannot do this with regular textures. Would i have to create a shape and fill it with the gold texture so I can delete that particualr gold piece? Thanks
I think you confuse Texture (which is basically a loaded image that you can draw) with game entities. Depending on how you implement your game, you can spawn multiple bodies (Box2D), actors (Scene2D) or your simple data containers (width, height, x, y) representing each coin and draw each one on the screen using the same texture. Actually, that's the preferred way to handle assets: you load images once and then simply reuse them for each sprite.
I suggest looking into the following classes:
Sprite (makes it easier to draw textures).
Image (allows to display simple images on Scene2D stage).
Box2DSprite (third party utility class that makes it easier to draw Box2D worlds).
In my game a player flys through space and has to avoid asteroids. Asteroids are just simple polygons which I draw using a Mesh class. For all the polygons I use just one Mesh class object and it works fine. To add a little variety to their looks I would like to use say 4 textures.
My question is, do I have to create different Mesh object for each texture or maybe there is a way to use just one Mesh class object? I read that it is best to use as little Mesh objects as possible to improve performance and since it is an Android game I certainly could use performance boost.
Inside draw method to bind one texture to a mesh I use this code:
mShaderProgram.begin();
mShaderProgram.setUniformMatrix("u_projTrans", mCamera.getCamera().combined);
Gdx.graphics.getGL20().glEnable(GL20.GL_TEXTURE_2D);
mTexture.bind();
mMesh.render(mShaderProgram, GL20.GL_TRIANGLES);
mShaderProgram.end();
I have to use Flash CS3, so I can't use the properties rotationX, roationY and rotationZ.
I have a movieclip, that looks like this. It is now flat, no 3D rotation or shearing
But what I want is that this movieclip has a rotationX, or that it is a bit in perspective like this:
As I said, I can't use rotationX, so I have been playing around with Matrix.
But I can not get it right.
Here is how I try to do it
myMC.transform.matrix = new
Matrix(1,0.15,0.35, 1, 0, 0);
And this is the result
Can you help me to get the matrix right, or is there another way?
Thank you,
Vincent
Make your life easier and just download a 3D engine for flash 9:
http://away3d.com/downloads
Either that or you can modify your CS3 installation to produce SWF files that target flash 10+
Sorry, rotationX and rotationY are not affine transforms (they obviously do not preserve parallelism between lines), so they cannot be represented by matrix multiplication in 2D space. It is, however, affine in 3D space (where the non-preservation of parallel lines is an apparent effect of the 2D projection, not of the rotation)
i believe what you are trying to do is to get a correct affine transformation matrix.
FYR (Transformation Matrix) http://en.wikipedia.org/wiki/Transformation_matrix
Edits
For more information about 3D transforms and their matrices,
Here, see if this applies.
http://www.cosc.brocku.ca/Offerings/3P98/course/lectures/2d_3d_xforms/
Edits 2
A blog post about 3D transform in CS3 and CS4.
3d Rotation the easy way: Buy Flash
CS4 uggh! I’m still using CS3 and only
for my Flash software. My illustrator,
photoshop, premiere, and aftereffects
are still at the lowly level of CS2
and for economic reasons, I’m stuck w/
my outdated software configuration for
awhile. But if you’re not in my boat
or on the same sea as my boat,
consider buying the latest, greatest
CS4 Flash to make 3D manipulation
inherent in flash display objects.
Yep, inherent, built in, easy.
In Flash CS3 and below, a display
object (i.e. sprite or movieclip) only
recognizes one rotation property
(rotation: Indicates the rotation of
the DisplayObject instance, in
degrees, from its original
orientation, which is usually the
upper left, corner or 0,0). This
property only rotates objects in the
2D flat space of the Flash stage. To
make 3D work in this flash, one must
“fake” it with math. Lots of math,
Points, lines, fills, trig, arrays,
and sometimes Matrices. Yippee kayae!
In Flash CS4 and above (as of writing
there is no above), a display object
(i.e. sprite or movieclip) recognizes
four (4) rotation properties. Holy
Cow! Yeah, four rotation properties:
rotation: Same as in CS3. 2D rotation.
rotationX: spin that shit around the X
axis of the stage, i.e. vertical
flipping. rotationY: spin it around
the Y axis of the stage, i.e.
horizontal flipping. rotationZ: spin,
baby spin o’er the Z axis of the
stage. As far as I’m concerned, a spin
around the Z axis is the same as
rotation (unless, for some reason, the
Z axis does not cross through the
orientation point of the object).
[http://actionscription.wordpress.com/2009/03/12/3d-rotation/]
what would be your recommendation for drawing shapes (rects, circles...) onto BitmapData, and how to effectively switch between colors.
Is there any way to get graphics context from BitmapData so I could easily paint shapes using graphics.draw...()?
Why do you want to use a BitmapData? Not sure what you're after, but after reading a couple of your questions it seems you're a kind of fighting against how flash works. I think you'll make things much easier for yourself if you use what's available already. BitmapData objects are meant mainly to manipulate pixels and don't expose methods for drawing shapes. A Graphics object (available through Sprite, Shape, etc) on the other hand, allows you to draw vector shapes easily.
So, the best approach for this, I guess, would be using the drawing API to do what you want and then, if needed, convert the graphic to a BitmapData.