How classes in Adobe Flash Professional works? - actionscript-3

I start before 1 year to use CS6 and I found some tutorials that explain how to make pltaformer games, I try a lot of tutorials they work great but for the code they use the timeline.
So, I make a game using the timeline but when I published it and running to my android device I have a lot of lag issues.
After a research I realized that coding in the timeline is a bad idea, also it's better to use Starling for making apps for mobile devices.
So I want to start again to learn how classes working.
I make a new project and I have 5 classes (Main, Level1, Hero, Ground and Enemy). I want the hero to interact with Ground (for gravity) and with Enemy (for hitTest), also Enemy have gravity so they must interact with the Ground.
The concerns are :
In which class I must write the hitTest function?
I have to write in Ground class the hitTest for Hero and the Enemy and in the Hero class to write the collision between the Hero and the Enemy
Or all of this functions must be write in Main class?

Related

Tutorials for cs5.5 + starling

I buy some 2d vectors , backgrounds , enemies , heroes and platforms.
i make already a game for android with adobe cs5.5 but i have some lag and gravity issues.
So, i decide to make it again from the start using starling.
The way i draw my game is simple.I like to have my enemies , coins etc to the stage and not dynamically add them.
So , is there a good tutorial for me to explain gravity , hit collision with ground and enemies?
Also i would like to know if writing a code in timeline or in classes is better or its not a big deal if the code is good written.
Thanks!

Box2D world.step() delay at first 2 runs

I'm programming a game using ActionScript 3.0 and included Box2D classes for its physics. It's a maze/labyrinth game having a lot of walls and a ball inside.
In my main fla when I call the maze.create(), the maze is created (visually and physically) and it will dispatch an event so I know when it's done working and then I call my frameHandler which calls another function from my maze class every frame and the big delay accrues exactly at world.step() in it. BUT THE THING IS that it lags only the first two times this function runs!!!
The reason I notice this lag, is that I've got another object starting to move according to mouse position in the same frame handler.
The reason I'm sure the world.step() is causing it, is that everything works fine when I dont call it.
I've seen many codes using Box2d, some had more objects than i have and I know that I've created my b2World and all the objects correctly, similar to all the Box2d tutorials and stuff BUT THEY DONT LAG AT ALL. Its just mine lagging and all!!
Do you have any Idea or similar experience?
Do you have any suggestion in general how to deal with heavy functions?
PLEEEEASE +.-
A maze will have a lot of fixtures in close proximity making a very dense dynamic tree (the method Box2D uses to optimize collision checks). There is unlikely to be any way around this. Perhaps you could just call Step a few times after adding the static walls, but before you add the dynamic ball bodies, and consider it part of the loading process. At least the lagging movements will not be visible to the player.

Action Script 3 - how to pass variables through multiple scenes

I am using flash cs6 and making a game in which some squares are falling down randomly and we have a wall that is controlled by the mouse. Every square we dodge 10 points are added to the score. If the squares touch the wall then we go to another scene called the "the end" scene in this scene we display the score to the player. So I want to pass the score variable to that scene. I have tried googling it a lot of times but it couldn't help. So my only hope is you guys. Please help.
How do I go to the next scene:
if (wall.hitTestObject(square))
{
gotoAndStop(1, "The End");
}
Instead of using flash to create games like this you can Game Maker it is more efficient.
You can go to its website yoyogames.com
Adobe Flash Professional Creative Suit series are for designers, animators. It is one of the worst IDEs for a programmer (notepad would be better). I'd suggest you to get a better IDE like Adobe's Flash Builder which is more suitable for programmers or search for other 3rd party IDEs like IntelliJ Idea which is one of the best from my point of view.
Instead of programming on timeline and using scenes which is for animators, get into the Object Oriented Programming, start with the basics, the classes, then move on with design patterns etc.

AS3 - What are the different methods of rendering animation on the screen?

I'm a beginner to AS3 and programming in general, but have learned enough that I want to now start learning how to render animations on the screen. These are the methods that I know of from two days of "researching" on google.
I'm not in a situation where I could afford to take courses from an educational institution, so my only means of learning are through online sources.
Update an objects x or y positions in a loop on every frame. Very basic. Of course any kind of advanced animation (say, showing a character running) is not possible with this method alone.
Using Flash and creating animation on a movie clip's timeline and, combined with moving the position of the object we can achieve some proper animation this way. However I cannot afford Flash, so this is not an option available to me. It also doesn't seem to be a popular option among more experienced programmers either (I think, due to having poor performance when lots of objects animating on the screen?)
Using a sprite sheet and then blitting the relevant image from the sprite sheet onto the screen.
Is there any other way to put an image from a sprite sheet onto the screen other than blitting?
And what other methods of rendering animation are available?
Some online websites claim that blitting is all I'll ever need, but I want to know all the options available so I could choose the most appropriate one for any given situation.
Any help would be appreciated :)
Another option for blitting is Stage3D. Take a look at Starling for 2D animations.
Blitting would be my best opinion. The only other thing I can think of is manually taking the images from the sprite sheet and putting it into each frame of an animation.
To render animation, you can create a frame in a MovieClip and convert it into a MovieClip and name the frame 'running'. Then you need to create an Enter Frame event where the MovieClip's instance name is 'Guy' and in the code on the function write 'Guy.x += 5;' to make your MovieClip go 5 pixels to the right every frame and also in the function write "Guy.gotoAndStop('running');"
Use TweenMax engine for better animation purposes. Easy coding, more Animation!!

Settings screen in Cocos2D game

How are settings screens created in Cocos2D games?
I've considered using a UIViewController subclass however pushing it in Cocos2D seems hacky. I've also considered using a CCLayer with buttons etc as child nodes. Then I could animate this layer in/out when appropriate. Is this the common way?
If you are using Cocos2D for your game, you should probably get in the habit of building your settings screens as Cocos2D scenes or layers, which offers the benefit of easily animating them into and out of the frame during your game. Adding a view controller is not necessary and actually complicates things when it is so easy to just create a CCScene or CCLayer.
I prefer the CCLayer approach, then I can animate the layer swooshing into the frame when a user presses a Settings button. The underlying game play is not erased since it is the same scene.
Another approach is to pop a settings scene onto the current scene.