CaptianKirk
21 posts
|
Topic: Game Programming /
Cursor Below Enemies - Need Help
Originally posted by Aesica:
Anti-AS2 comments aside, you can fix this easily by using containers instead of simply tacking everything onto root. So:
// do this only at the beginning when intializing your gamefield. You should actually probably declare them as private, up at the top (or public if your code is messy)
var mEnemyContainer:MovieClip = _root.createEmptyMovieClip("enemyContainer", _root.getNextHighestDepth());
var mCursorContainer:MovieClip = _root.createEmptyMovieClip("cursorContainer", _root.getNextHighestDepth());
// ...later on
// the cursor will always be above the enemies, no matter how many enemies you try to attach.
var someCrappyEnemy:MovieClip = mEnemyContainer.attachMovie("Goblin", "Goblin" + mEnemyContainer.getNextHighestDepth(), mEnemyContainer.getNextHighestDepth());
My custom cursor is controlled by frame code. It’s based off of the root. How would I make the previous code work? Also, how would I have the enemies spawn with the previous code, because I’m using the attachMovie method in an external class to attach enemies?
Mouse.hide();
onMouseMove = function()
{
cursor._x = _xmouse;
cursor._y = _ymouse;
}
|
|
|
CaptianKirk
21 posts
|
Topic: Game Programming /
Cursor Below Enemies - Need Help
The custom cursor I’m using for my game is always below spawned objects(the enemies). I don’t know how to fix this. To attach the enemies, I’m using the attachMovie method with getNextHighestDepth. I was thinking about using the swapdepths method, but I have no idea on how to use that. The cursor is on the stage to begin with. I am using AS2. Please Help.
|
|
|
CaptianKirk
21 posts
|
Topic: Game Programming /
Text into infinity
In the intro movie for my game, I need to have some text marching into infinity. Kinda like the into for star wars. But, I don’t know how to make it look right. I have the publish settings for as2, so no 3d rotation. Could someone tell me how to do this?
|
|
|
CaptianKirk
21 posts
|
Topic: Game Programming /
Remove animation after completion
Originally posted by BigJM:
Is the Egg added at runtime or in the IDE?
The egg is added at runtime.
Also, why would a removeMovieClip() not work?
|
|
|
CaptianKirk
21 posts
|
Topic: Game Programming /
Remove animation after completion
I tried adding the removeMovieClip(). It still doesn’t work, At the end it just sticks to the player and repeats again into infinity.
|
|
|
CaptianKirk
21 posts
|
Topic: Game Programming /
Remove animation after completion
It was in the last frame, but I removed it when it wasn’t working. Would it have worked?
|
|
|
CaptianKirk
21 posts
|
Topic: Game Programming /
Remove animation after completion
Originally posted by DrYoshiyahu:
I hate telling anyone to code on the timeline, but what you can do is simply remove the movieclip on the movieclip’s last frame.
I tried doing just that with this code at the last frame of the movieclip.
removeMovieClip(this)
Originally posted by BluePriest:
put a trace in to make sure its even registering that the current frame is == to the total frame
if (this._currentframe == this._totalframes)
{
trace('current == total');
this.removeMovieClip();
}
Im guessing you have it stopped because this IS the explosion? and the egg explodes once it hits something?
Originally posted by BluePriest:
put a trace in to make sure its even registering that the current frame is == to the total frame
if (this._currentframe == this._totalframes)
{
trace('current == total');
this.removeMovieClip();
}
Im guessing you have it stopped because this IS the explosion? and the egg explodes once it hits something?
I used the trace. It returned: “current == total”
Thanks
|
|
|
CaptianKirk
21 posts
|
Topic: Game Programming /
Remove animation after completion
I can’t remove an animation when it’s finished. It’s all written in AS2. The object is like a missile. I’m trying to get the animation to start when the object hits the player or falls to the ground. Then remove itself after the animation completes. But, it won’t remove itself. Help!
Here’s my code:
class Egg extends MovieClip
{
var hit:Boolean = false;
function onLoad()
{
stop();
}
function onEnterFrame()
{
if (this._currentframe == this._totalframes)
{
this.removeMovieClip();
}
if (hit == false)
{
this._y += 10;
}
if (hit == true)
{
this._x = _root.player._x;
}
if (this.hitTest(_root.player))
{
play();
if (hit == false)
{
hit = true;
this._y + 40;
_root.player.updateHealth(-10);
}
}
if (_y > 500)
{
play();
hit = true;
}
}
}
|
|
|
CaptianKirk
21 posts
|
Topic: Game Programming /
NumericStepper. Need Help! [AS2]
OK, I did what you said, how come in my trace:
trace(x1)
The value comes up as “undefined”. How do I get it to return a real number value?
|
|
|
CaptianKirk
21 posts
|
Topic: Game Programming /
NumericStepper. Need Help! [AS2]
I’m trying to make a distance formula solver program, formula(square root of (x2 – x1)^2 + (y2 – y1)^2), and to make it I’m trying to use a NumericStepper and fetch it’s value. How do I fetch’s value properly? I would to use a class file because that’s what I’m used to but fully explained frame code would be fine.
Here’s the way I was trying to get the value:
class Answer extends MovieClip
{
var x1:Number;
var x2:Number;
function onLoad()
{
x1 = _root.valX1.NumericStepper.value;
x2 = _root.valX2.NumericStepper.value;
}
}
This class is for the MovieClip with the answer in it. It has some text along with dynamic textbox on the same layer.
|
|
|
CaptianKirk
21 posts
|
Topic: Game Programming /
Making a "onMouseDown = function()" repeat
I didn’t copy&paste any code except for the frame code which I am not using. I’m only using the class file.
And I do know what’s going on my code.
Also, have you even written any actionscript, because I don’t see any games on your profile, NineFiveThree?
|
|
|
CaptianKirk
21 posts
|
Topic: Game Programming /
Making a "onMouseDown = function()" repeat
I need to make an gun in my game so that when the left mouse button it starts shooting until the button is released. This is all as2.
I ported some frame code to class files. I didn’t write this frame code, I only ported it to class files. Also I only included 1 of the classes.
Frame Code:
/**
* Game Engine - Shooting Projectile Bullets
*
* Version: 1.1
* Author: Philip Radvan
* URL: http://www.freeactionscript.com
*/
//Settings
var bulletOffset:Number = 10; //pixels - bigger number = less acurate
var bulletLifeTimerTotal:Number = 20; //fps
var bulletSpeed:Number = 10; //pixels
var reloadSpeed:Number = 200; //ms 1000 = 1 second
//Declare variables that we're going to be reusing
//(this saves them in memory thus speeding everything up a little)
var reloadTimer:Number;
var reloadComplete:Boolean = true;
var bulletAngle:Number;
var randomNum:Number;
var playerX:Number;
var playerY:Number;
var rotationDirection:Number;
/**
*
* Fire Weapon
*
*/
function fireWeapon():Void
{
//check if weapon is reloaded, if true, fire bullet
if(reloadComplete == true)
{
//attach bullet
var bullet_mc:MovieClip = _root.attachMovie("bullet", "b"+_root.getNextHighestDepth(), _root.getNextHighestDepth());
//position bullet on player
bullet_mc._x = player_mc._x;
bullet_mc._y = player_mc._y;
bullet_mc.bulletLifeTimer = 0;
//calculate random bullet offset.
randomNum = random(bulletOffset)-(bulletOffset/2);
//set bullet firing angle
bulletAngle = ((player_mc._rotation+randomNum-90)*Math.PI/180);
bullet_mc.xSpeed = Math.cos(bulletAngle)*bulletSpeed;
bullet_mc.ySpeed = Math.sin(bulletAngle)*bulletSpeed;
//make it move
bullet_mc.onEnterFrame = function() {
//move bullet
this._x += this.xSpeed;
this._y += this.ySpeed;
//
//check if bullet needs to die of old age
if (this.bulletLifeTimer>=bulletLifeTimerTotal) {
this.removeMovieClip();
}
//update bullet timer
this.bulletLifeTimer++;
};
//start reloading gun
startReloading();
}
}
//start reloading weapon
function startReloading()
{
reloadComplete = false;
//set a timer that will call the gunReloaded function after "reloadSpeed" time passes
reloadTimer = setInterval(this, "gunReloaded", reloadSpeed);
}
//gun reloaded function - clears timers and sets reloaded to true
function gunReloaded()
{
clearInterval(reloadTimer);
reloadComplete = true;
}
//Rotate Player
function rotatePlayer()
{
//update our player location parameters
playerX = player_mc._x;
playerY = player_mc._y;
//calculate player_mc rotation, based on player position & mouse position
rotationDirection = Math.round(180 - ((Math.atan2(_root._xmouse - playerX, _root._ymouse - playerY)) * 180/Math.PI));
//set rotation
player_mc._rotation = rotationDirection;
}
/**
*
* Mouse Controls
*
*/
//create an object that we'll listen to
mouseListener = new Object();
//on Click, fire the weapon
mouseListener.onMouseDown = function() {
fireWeapon();
};
//on mouse move, rotate the player
mouseListener.onMouseMove = function() {
rotatePlayer();
}
//add listener
Mouse.addListener(mouseListener);
Now here’s the code I used:
class Turret extends MovieClip
{
var reloadTimer:Number;
var reloadComplete:Boolean;
var turretX:Number;
var turretY:Number;
function onLoad()
{
reloadTimer = 10;
reloadComplete = true;
}
function onEnterFrame()
{
rotateTurret();
onMouseDown = function()
{
if (reloadComplete == true)
{
var bullet = _root.attachMovie("bullet", "b" + _root.getNextHighestDepth(), _root.getNextHighestDepth());
bullet._x = this._x;
bullet._y = this._y;
reload();
}
}
}
function reload()
{
reloadTimer = setInterval(finshedReloading, reloadTimer);
}
function finshedReloading()
{
clearInterval(reloadTimer);
reloadComplete = true;
}
function rotateTurret()
{
turretX = this._x;
turretY = this._y;
var rotationDirection = Math.round(180 - ((Math.atan2(_root._xmouse - turretX, _root._ymouse - turretY)) * 180 / Math.PI));
this._rotation = rotationDirection;
}
}
|
|
|
CaptianKirk
21 posts
|
Topic: Game Programming /
Custom Cursors using Classes AS2 Help
Yes, I checked the box “export for actionscript” and filled in the class field.
|
|
|
CaptianKirk
21 posts
|
Topic: Game Programming /
Custom Cursors using Classes AS2 Help
I’m trying to make a custom cursor in flash using as2. However the code can’t be frame code, because I’m using class files to make it. And also I prefer to use class files as it’s easier to debug.
Here’s some of the code that I’ve tried.
class Cursor extends MovieClip
{
function onEnterFrame()
{
_root.cursor._x = _xmouse;
_root.cursor._y = _ymouse;
}
}
And yes I did try changing the instance name “cursor” to a different name.
Thanks
|
|
|
CaptianKirk
21 posts
|
Topic: Game Programming /
Help finding good tutorials to learn AS3
I can’t find a good tutorial that explains the code. All the tutorials I find are simple copy and paste into your file.
Could someone point me towards a good tutorial for AS3?
Also, where did you learn how to program AS3?
|
|
|
CaptianKirk
21 posts
|
Topic: Game Programming /
Frame Code with Scripts?? AS2
Here’s the preloader I used:
<http://www.flashvalley.com/fv_tutorials/creating_a_preloader_in_Flash/>
I tested the preloader in my scoutship game. I didn’t post it. but when I tried it, the frame code took precident over my external scripts. The scoutship game is based on kongregate’s shootorials. I just moved all the game frames over to frame 2. And put the preloader into a single layer code and all.
Edit: I didn’t post the “preloader test scoutship” just the “Original Scoutship”
|
|
|
CaptianKirk
21 posts
|
Topic: Game Programming /
Frame Code with Scripts?? AS2
But when I use frame code for a preloader, Flash ignores the scripts. That’s the problem. And what is #include;
|
|
|
CaptianKirk
21 posts
|
Topic: Game Programming /
Frame Code with Scripts?? AS2
I know I asked this question before, but all the answears were for as3 and not much help in telling me how to combine frame code with external scripts.
I use as2.
How do I use frame code with scripts?
|
|
|
CaptianKirk
21 posts
|
Topic: Game Programming /
Frame Code with Scripts??
Can I use frame code with external scripts? I’m trying to make a game using both frame code for somethings, like the shooting engine and the preloader. And external scripts for other things, like movement and enemy attachment.
|
|
|
CaptianKirk
21 posts
|
Topic: Technical Support /
Not Receiving API Rev. Share
I uploaded a new game about 2 days ago. I have both the exclusivity bonus and the API bonus. However, I am not receiving the API share of 10%. And I know I have the Stats API in right because there’s a high score list. I am currently receiving 40% instead of the 50% I should be.
|
|
|
CaptianKirk
21 posts
|
Topic: Game Programming /
Make a Cash function for Upgrades
Could anybody tell me how to make when you push a button in flash to change variables, subtract a set amount from cash, and to prevent the cash from getting below a certain amount? Also, how the code works.
I use ActionScript 2
|