The Armor Games website will be down for maintenance on Monday 10/7/2024
starting at 10:00 AM Pacific time. We apologize for the inconvenience.

ForumsProgramming Forumneed help with some programing

3 4443
duhcornmaster
offline
duhcornmaster
64 posts
Nomad

ok here's the deal
i have cs5
i know how to use some of the basic flash stuff and i can draw pretty well with my tablet in photoshop
but i would like to learn some basic gaming stuffs like having a symbol in flash move when you press a key and having other symbols interact (bullet hits bad guy, bad guy screams and his head explodes etc)
i have some background with html but i doubt that that has anything to do with this. so basically i would just like to have somebody walk me through the basics.

  • 3 Replies
master565
offline
master565
4,104 posts
Nomad

i have some background with html but i doubt that that has anything to do with this.


The only time HTML is used in flash is for text formating i believe.

If you have any specific questions you can ask them here stackoverflow.com/

And here's a nice way to simulate gravity

Gravity, friction, elasticity, ect
var exampleX:Number = 50; //our movie clips X postion
var exampleY:Number = 200;//our movie clips Y postion
var exampleS:Number = 20; //our movie clips speed
var exampleV:Number = -1; // our movie clips velocity


//adding a movie clip to the stage
var example:MovieClip = new exampleMC()
addChild(example)
example.x = exampleX
example.y = exampleY

//running a function every frame
addEventListener(Event.ENTER_FRAME, gravity, false, 0 ,true) //false, 0 , true, are used for garbage collection



function gravity(e:Event)
{
example.y = exampleY;
exampleY -= exampleS;
exampleS += exampleV;
}
/*what this function does is every frame add X to the MC's speed
subtract Y from X slowing its path until X is a negative number
and its path is reversed*/
master565
offline
master565
4,104 posts
Nomad

Heres how to check for collisions

var example:MovieClip = new exampleMC()
addChild(example)
example.x = 50
example.y = 100

var example2:MovieClip = new exampleMC()
addChild(example2)
example2.x = 400
example2.y = 100

addEventListener(Event.ENTER_FRAME, movement)

function movement(e:Event)
{
example.x += 4; //just moves our first MC foward
}

addEventListener(Event.ENTER_FRAME, collision, false, 0 ,true)

function collision(e:Event)
{
if (example.hitTestObject(example2)) // test if our first MC touches our second MC
{
removeEventListener(Event.ENTER_FRAME, movement) //removes our other function making the ball stop
}
}

master565
offline
master565
4,104 posts
Nomad

Just a thing to know about adding event listeners, UNLESS your planing to remove the event later, you should always add false, 0 , true to the end of that listener parameters

example: addEventListener(Event.ENTER_FRAME, example, false, 0 ,true)

Showing 1-3 of 3