Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.

Cheers,
Kirupa

Results 1 to 3 of 3

Thread: More BitmapData woes

  1. #1

    More BitmapData woes

    I've recently tried to take my bitmapdata skills to the next level by creating my own animation and rotation classes to help bring life to a sitll image. However I might have set my sights a bit too high when I tried to create a multi-dimensional array that pre-compose all the necessary images for proper rotation, scale and opacity. I ALMOST have it but due to my lack of skill with matricies, I can't figuire it out :/ Here's what I got so far :

    PHP Code:
    var SRO:Array = new Array();
    for (var 
    i:uint <= 10 i++){
        var 
    newWidth:uint  width * (i+1)
        var 
    newHeight:uint height * (i+1)                                                                
        
    SRO[i] = new Array();
        for (var 
    ii:Number = -18ii 19ii++){ 
            var 
    rotationMatrix:Matrix = new Matrix();                        
            var 
    temp:Number Math.sqrt((newWidth/2)*(newWidth/2)+(newHeight/2)*(newHeight/2)); 
            
    rotationMatrix.identity()
            
    rotationMatrix.translate(-newWidth2,-newHeight 2); 
            
    rotationMatrix.rotate(ii Math.PI/180 10);                 
            
    rotationMatrix.translate(temp,temp);
            
    rotationMatrix.scale(i+1,i+1);                    
            
    SRO[i][ii] = new Array();
            for (var 
    iii:uint iii <= 10 iii++){    
                var 
    ct:ColorTransform = new ColorTransform(1,1,1,iii*.1);
                
    SRO[i][ii][iii] = new BitmapData(temp*2,temp*2,true,0);                                
                
    SRO[i][ii][iii].draw(this,rotationMatrix,ct);
            }
        }                            

    So SRO[0][0][10] would be a scale of 1, and rotation of 0 and opacity of 100%.

    Rotation(ii) and opacity(iii) work fine, but for some reason it only scales the bmd's bounds and not the image itself.

    On a side note, how do I get rid of the background of a bmd alltogether? Example attatched

    **edit**apparently my host is down, anyone know where I can upload multiple files (including swf)temp link
    Last edited by substance; April 18th, 2008 at 10:17 PM.

  2. #2
    Create a class called texture to manage the rotation textures and give it a function where you can pass in an angle in radians and it will return the required texture. Like texture.GetTexture(0); will return textures[0] in the class since that represents 0 degrees. Also make the constructor so you can say the number or rotations like 35 and such.

    Do you not understand how opacity works? Look up alpha blending. You don't have to store the rotated images and their opacities.
    Last edited by Sirisian; April 18th, 2008 at 11:47 PM.

  3. #3
    Quote Originally Posted by Sirisian View Post
    Create a class called texture to manage the rotation textures and give it a function where you can pass in an angle in radians and it will return the required texture. Like texture.GetTexture(0); will return textures[0] in the class since that represents 0 degrees. Also make the constructor so you can say the number or rotations like 35 and such.

    Do you not understand how opacity works? Look up alpha blending. You don't have to store the rotated images and their opacities.
    I could create a texture manager but I prefer just having each object have a "rotationArray" that I can directly grab images from. I might create a manager in the future but now I'm just trying to get everything working.

    Anyways, I havent heard of alpha blending. I got the idea of precomposing everything from the birchlab experiements and I saw that he had a sprite sheet that included transparency so I assumed it had to be done similarly. After doing a quick search I assume you're reffering to the "alphaBitmapData" parameter in the copyPixels method?

    Btw,Sirisian, I just wanna thank you for all your extremely helpful posts in the past. I know you havent helped me directly but pretty much everything i've learned on this subject are from archived post you have made along with things like the tank game and your texture manager. The "introduction" to bitmapdata was also very informative.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012