ActionScript 3.0 :: How To Store Objects In Game
Feb 18, 2009
Suppose I have a list of 100 enemies on the stage like this (pseudocode):
Code:
// init:
enemies = new Array();
for (i=0; i<100; i++) {
temp = new Enemy(a, b, c);
stage.addChild(temp);
enemies.push(temp);
}
Now enemies is an array of all the enemies, so I can update all of their positions, and other properties, each frame. Is this a good way to do things? Because I just realized that I'm storing each enemy twice: One time in enemies Array and one time in stage.children. Maybe I should get rid of the enemies Array altogether, and just use stage.getChildAt() to update the enemies?
View 1 Replies
Similar Posts:
Aug 22, 2011
I am currently developing a game in iOS / Android and I encounter a problem. If I am playing a game mid-way and if a person phones up, my game is still running, how is it possible to store the state of game so that I can continue to play after I put down the call?
View 1 Replies
Jul 4, 2010
currently i making this game and objects would spawn at random and be able to click but when de game starts itself, the spawn is correct but i am unable to make it stop when time goes to 0seconds.
View 1 Replies
Jun 3, 2009
And one more, im still new to flash and im thinking which database is best to be used for flash. i got some ideas in SQL server and Microsoft Access.
View 1 Replies
Mar 22, 2010
I am making some word game I need to save my data into PC. I don't know How to do it.
View 6 Replies
Mar 8, 2012
Is there a way for Flash to store content that will not be deleted with the browser's cache?Imagine a game that runs in the browser but is still heavy enough that you don't want your users to go through downloading assets again every time.Now that LSO obeys browser cache deletion (it does, right?), is there another way? Using Air would work but you'd have to download and install a client, which defeats the purpose of browser games.
View 2 Replies
Feb 9, 2004
I am making a game url...).I want you to be able to buy a gun from the store and then that goes under your gear which you can then choose to use before a match.I do not know how to make it so when you buy a Pistol and a rifle they show up in your gear, Then make it so that when you select the pistol then when you start the round, you will have the pistol and not the rifle.
View 2 Replies
Dec 18, 2010
I want to make my games savable. What would be the best way to store and retrieve the data? I plan on storing them in a mySQL database and retrieving them as XML. Should I give each game its own table and each variable its own column (with a row for each user)? Or should I just put all saved games into a table and store all variables in one cell? How should I retrieve them?
View 7 Replies
May 3, 2007
I'm making a top-view side-scrolling racing game in Flash AS3. I'm unsure about the best way to store levels in the game.
View 1 Replies
Oct 28, 2010
Since Apple loosened their terms again, is it posible to develop a game in FLash CS5 and publish it on the Apple App Store? Are there actually any real apps / games on the App Store that were build on Flash?
View 1 Replies
Nov 4, 2009
I have an array name region it has a couple of properties. "code", "name", "value"
I want to store this array in an indexed object called regions.
I would then like to access the object by referring to its sub property name
regions[1].code
regions[1].name
regions[1].value
[Code]...
Can someone outline the variable definition and construct so I can access this information. Happy to replace the index field with the code value.
View 0 Replies
Jun 1, 2010
I've had the nagging thought of eventListeners vs container looping. For example, you could create a bunch of objects and store them in an array; make a loop that traverses the array and tells each object to execute a method. In contrast I could tie an eventListener to the object in it's constructor function that tells it to perform a task every frame.
View 6 Replies
May 6, 2007
I'm just trying to store a simple cookie that will remember the score for the next time the user plays the game (the score governs if an option is visible or not)It all works fine until I close browser/reload the page, at which point the shared object seems to disappear, any clues?
Write:
Code:
var rem_score:SharedObject = SharedObject.getLocal("score");
rem_score.data.score = new Number(score);
rem_score.flush();
The problem prolly lies in my write code but ill post the reading aswell just incase there is a problem with that too
Code:
var rem_score:SharedObject = SharedObject.getLocal("score");
if (rem_score.data.score != undefined) {
this.remdscore = rem_score.data.score;
if (rem_score.data.score >=30) {
[code]...
There is another point it is read but it is the same sort of thing as the above.
View 1 Replies
Dec 30, 2009
I am making sims like game and right now I am trying to figure out how I will structure my objects. right now I am thinking to create a class called GameObject, the psuedo is below
public class GameObject {
name:String
width:int
height:int
}
This way I could create objects like bushes, trees, and buildings. But then I began to think. what if I wanted to create multiple buildings and trees of the same type ?? I would have to keep making instances of GameObject and giving it a new name and height and width. The properties would have to be the same values in order for me to duplicate one object. That seems a little tedious. Then I figure , maybe that isnt the right way to go. So I was thinking, I would have to extend GameObject like below
public class Tree extends GameObject{
birdHouse:Boolean
}
public class Building extends GameObject{
[code].....
Now this way I can create a class that has a method that loosely accept accepts any type that inherits GameObject.
Selector.loadObject(gObject:IGameObject);
Depending on what type it is (i.e tree, building, house) I can use a case statement to figure out which type it is and evaluate it accordingly.
I also created a Tile Class that will pass through the loadObject method. It also will be a child of the GameOject class. if the case statement finds that it is type Tile, it will highlight whatever Tile depending on what tile my mouse is over.
My second question is if a class inherits a class that implements a interface, is that class child class considered to be a IGameObject as well. or does it have to implement that interface directly. does all this sound like I am going in the right directions lol, as far as organization is concerned.
View 3 Replies
Sep 15, 2010
I'm starting with actionscript 2 and I can't figure out how I set a collision mask for enemies and characters. I've got birds that flap their wings but I only want the player to collide with the body, not with the wings, as they take up too much space and it would be unfair.
I tried mc.setMask and other things I found online, but somehow it didn't work, ie: did nothing. I think I don't get the way this works. I thought you'd need like an invisible rectangle that it checks collisions against instead of the actual animation.
View 11 Replies
May 10, 2009
I'm trying to develop a SWF Api that consists of a game that makes random objects fall from the top, each of them has different points, and then the points the player gets should be stored into a dinamic text called score, when the player doesn't take the ball, loses a life. Then, if the player catches it, the ball disappears and gives the points to the player.
View 3 Replies
Oct 25, 2006
How would I create a brand new movieclip and then dynamically add two or more existing movieclips to it(not talking about API)?
View 5 Replies
Mar 16, 2010
I am having a problem with my collision game. When I try to make collision between 2 objects, this occurs: TypeError: Error #1009: Cannot access a property or method of a null object reference. at Level$iinit().
Here is my PHP Code:
package {
import flash.display.*;
import flash.events.Event;
import flash.geom.Point;
import flash.events.Event;
import flash.events.MouseEvent;
public class Level1 extends MovieClip {
[Code] .....
My flash file is at [URL].
View 1 Replies
Jul 5, 2011
trying to color objects that are flying around in my space game.When I shoot and hit them - the affected enemies shall blink. The graphics are pre-rendered (i.e. there's an rotation array and function where the degrees and their appropriate rotation for the objects are stored / calculated for better performance).
So - my idea was to enhance that rotation function with a functionality for additional coloring; but the colored AND rotated objects shall be stored apart of the normal rotated objects. To accomplish this I made a nested array:in row one there are 360 rotated graphics of one object and in row two there are 360 graphics of a rotated and colored object.
Problem: Coloring works but they are not rotated (always at 0 degrees).
Code:
public function createRotationWithColorBlitArrayFromBD(sourceBitmapData:BitmapData, inc:int, offset:int = 0):Array
{
trace("sourceBitmapData.width=" + sourceBitmapData.width);
[code]....
View 4 Replies
Jan 27, 2011
I am designing a simple classify drag and drop game, but I got several objects and targets, for example square shape object can only go to square shape target, however when I have 2 or more square, then the square2 and square3 can not go to square target!
Code:
var objectoriginalX:Number;
var objectoriginalY:Number;
var counter:Number = 0;
triangle_mc.buttonMode = true;
triangle_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickupObject);
[Code] .....
View 3 Replies
Oct 10, 2011
I am attempting to create a game that will simulate groceries coming down a conveyor belt. The player acts as a bagger and must click and drag the groceries into designated bags (one for cold food and one for non-cold food). When the correct choice is made the food will disappear and the score will increase +1.
I have become overwhelmed by thinking about how to do this and have not found helpful answers that actually work when I try to compile them so I decided to ask. how I can have random grocery items fall down the screen? I assumed I could create an array of movieclips and have them be called to fall down randomly, but I am not sure how this would work.
View 2 Replies
Jul 8, 2009
I'm creating a game-engine, which will add objects to itself as symbols, and I want to be able to choose how they are "layered". For example, say I decide to model things in a type of 3D, and the Z co-ordinate is used for depth (distance from front), how would I translate this into an object 1 unit away rendering in front of an object rendering 2 units away? The engine programming I've done fine in terms of calculating the values etc., as I have a strong javascript background so that was the easy what with actionscript's neat OO syntax, but getting it to do things visually is a bit problematic know, heh. So far all I've really managed is a nice little loading bar, which isn't really that hard =D
Also, the symbols I create are actually going to be comprised of multiple parts; a base-layer, a detail-layer, and a colour-layer. What is the easiest way to do this? Ideally I'd create the symbol with multiple layers of its own, and simply toggle the detail and colour-layers on/off as required, and tint the colour-layer independently of the rest of the symbol. Is this possible? Or will I need to use multiple symbols and move them in tandem myself?
View 4 Replies
Jun 26, 2009
I'm doing this object oriented game and I create a bunch of 'boxes' via a for loop
Code:
Select allfor (var z=0; z < numOfBoxes; z++){
var box:Object = new Object();
box.mc = new Box();
box.mc.name = "box"+z
box.mc.x = Math.round((Math.random()*(530-box.mc.width)) + 20);
for (var i=0; i<boxXArray.length; i++){
[Code] .....
I get my random amount of boxes scattered over my stage (I haven't put in any checks to see if they are touching). How do I 'name' these boxes so I can reference them later? Say I want to move the .x of boxA in another function? Is there a simple way to call them box+z instead of just all as box? (Then I can run them through a loop later to talk to them).
View 2 Replies
Sep 2, 2003
I am trying to make a game where you have random objects falling vertically and must land in a bucket. The bucket is controlled by the mouse(it follows the mouse).
View 5 Replies
Dec 13, 2009
I'm trying to make a flash game have save files using shared objects and I'd like to keep all the data in one file with several children.
The three things I'd like to do are:Check whether the file exists (create a new file if it doesn't), then check whether to child named with text in an imput box exists, and if it doesn't create a new file (using the text in an imput box), and then set the value of that node to 0.
Then later I'd like to change that node to another number (the easy part).I'd also like there to be a way to disable the shared objects (incase the user doesn't allow shared objects).I've tried to do this myself using a few tutorials, but I could get it to work.I couldn't use the text in the input box to name the child,and I couldn't check the size of the child node to see whether it existed or not.
View 2 Replies
Jan 5, 2010
I have some data (preferably objects, insteads of string) in the flash which I want to store as table format. So that I can query them. It is not datagrid as I do not have to show them. Currently, I am use "xml class" because of the query function. However, "xml class" cannot store objects.
View 1 Replies
Nov 30, 2011
How do you rotate objects 45 degrees using arrow keys for making a pacman game?
View 13 Replies
Mar 7, 2012
I am going to develop a very simple game for android and for iphone/ipad I have the option to develop it in cocos2d or in adobe flash air (i am not a developer, but i have 2 developers who are offering me the service)I have a developer that states that cocos2d is better and other one that states that adobe flash air.I want it in cross platform.the cost offered by both developers is the same..i have heard that adobe air has the flaw that it is very slow, is this real? if you had the 2 options which will you use to develop your game and why?
View 1 Replies
Apr 24, 2011
I'm making a game that populates user-designed cards into the game using an external xml file. My main class loads the xml file and then calls to the "Card" class, which wants to use the xml file. I've tried using this.parent and it just gives me a null object reference error. This is what I have so far: Main.as
[Code]...
View 2 Replies
Feb 28, 2011
I'm creating a game at the moment for my university course and it involves the player character jumping on top of boxs twice to break them as opposed to just once.What would be the most efficient/simple way of writing this in Actionscript 3.
View 1 Replies