• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

How do I make items/powerups come with in the next scene?

Community Beginner ,
Jul 06, 2024 Jul 06, 2024

Copy link to clipboard

Copied

I have a basic problem I think, when the character touches items/powerups they'll go into itemslots. But when the character touches a door or heads to the next scene/stage (not a frame), the items/powerups are not in the itemslots anymore even though I added them to the next scene (mainly their just outside the itemslots).


How do I get the game to keep the progress as the character enters other scenes/stages? 
I don't know if flash games only work on one scene or if I setup arrays or sharedobjects.

TOPICS
ActionScript , Code , Missing feature , Other , Timeline

Views

422

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 06, 2024 Jul 06, 2024

Copy link to clipboard

Copied

using scenes means you have to redo anything you want to carry from one scene to the bext.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 07, 2024 Jul 07, 2024

Copy link to clipboard

Copied

So should I just try to put it kinda like all one scene instead? 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 07, 2024 Jul 07, 2024

Copy link to clipboard

Copied

you can either use one scene (and mimic scenes by use keyframe with labels), or use code (eg, a data object that saves data so whatever is needed in other scenes can be restored).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 07, 2024 Jul 07, 2024

Copy link to clipboard

Copied

any tutorials on data objects then?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 07, 2024 Jul 07, 2024

Copy link to clipboard

Copied

too simple for a tutorial:

 

on your main timeline, create it:

 

var dataObj:Object = {};

 

then when you want to save something eg, lives or a player name, use

 

dataObj["lives] = 1;

dataObj["name"] = "madman";

 

if you want to increment lives

 

dataObj["lives"]++;
or decrement 

dataObj["lives"]--;

 

to retrieve data

 

if(dataObj["lives"]<1){
gotoAndStop("gameover");

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 07, 2024 Jul 07, 2024

Copy link to clipboard

Copied

so I just go to main timeline (like character or vcam?) Because I'm trying create a powerups like magic jewel or extra lives like this:

var dataObj:Object = {magicjewel};

 

dataObj["powerup"] = 1;

dataObj["name"] = "magicjewel";

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 07, 2024 Jul 07, 2024

Copy link to clipboard

Copied

no.  

 

if you want to store magicjewels, you probably want to save the number of jewels in the players inventory.

 

var dataObj:Object = {};

 

// for numeric items you can use addNumericItemsF by passing the string you want to store/increment

 

function addNumericItemsF(s:String):void{
if(!dataObj[s]){
dataObj[s]=1;

} else {
dataObj[s]++;

}

}

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 07, 2024 Jul 07, 2024

Copy link to clipboard

Copied

Well really theres only one. Its supposed to be like saved in itemslots. Is there a way to do that? Sorry I forgot to mention.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 07, 2024 Jul 07, 2024

Copy link to clipboard

Copied

save using he dataObj and assign the value to whatever you're calling an itemslot

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 07, 2024 Jul 07, 2024

Copy link to clipboard

Copied

Mainly the itemslots are the inventory, you see I set the inventory to be a bunch of itemslots in a rectangle/box. 
1. What would the main timeline be exactly?
2. var dataObj:Object = {itemslot}; is this the correct way to put it?

3. would I have to save the items data (although there is only one of each) in the layers of the itemslots? 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 07, 2024 Jul 07, 2024

Copy link to clipboard

Copied

2. no. see my previous posts. they all initialize daraObj with the same line of code.

3. there's not always one of each, correct?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 08, 2024 Jul 08, 2024

Copy link to clipboard

Copied

Really there is only one of each. Its like quest items basically.

 

var dataObj:Object = {};

dataObj["magicJewel"] = true;

dataObj["magicHourglass"] = false;

dataObj["magicWand"] = true;

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 08, 2024 Jul 08, 2024

Copy link to clipboard

Copied

yes, that would work, but it's less flexible than using 1's and 0's.  but if that's what you want to do, go for it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 08, 2024 Jul 08, 2024

Copy link to clipboard

Copied

Well is there anything else I need to add to the code like the if statement to retrieve data?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 08, 2024 Jul 08, 2024

Copy link to clipboard

Copied

that depends on what you use to "fill slots" when changing scenes.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 08, 2024 Jul 08, 2024

Copy link to clipboard

Copied

Well what would be good to use to fill slots when changing the scenes then?


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 08, 2024 Jul 08, 2024

Copy link to clipboard

Copied

how do/did you fill a slot in the first scene?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 08, 2024 Jul 08, 2024

Copy link to clipboard

Copied

Mostly I added a code to the frame the itemslots were in and a code to the items.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 08, 2024 Jul 08, 2024

Copy link to clipboard

Copied

again, what code?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 08, 2024 Jul 08, 2024

Copy link to clipboard

Copied

Are you talking about for items or itemslots or for the one I sent:

var dataObj:Object = {};

dataObj["magicJewel"] = true;

dataObj["magicHourglass"] = false;

dataObj["magicWand"] = true;

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 08, 2024 Jul 08, 2024

Copy link to clipboard

Copied

what code do/did you use to fill a slot in the first scene?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 08, 2024 Jul 08, 2024

Copy link to clipboard

Copied

I mainly used an ai code generator for this. Sorry if it looks confusing or wrong.

 

This is the one for items:

addEventListener(Event.ENTER_FRAME, onEnterFrame); function onEnterFrame(event:Event):void { if (char.hitTestObject(this)) { addToSlot(this); } }

 

This is the one for Itemslots:

var currentslotnum:int = 1; stop(); function addToSlot(magicjewel:DisplayObject):void { if (!magicjewel["found"]) { magicjewel.x = root["itemslot" + currentslotnum].x; magicjewel.y = root["itemslot" + currentslotnum].y; magicjewel["found"] = true; root["itemInSlot" + currentslotnum] = magicjewel; // Store item in root currentslotnum++; } }

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 08, 2024 Jul 08, 2024

Copy link to clipboard

Copied

how to you know which item slot num to use or do you just store them willy-nilly?  ie, a powerup might be in the first slot or last slot (depending only on previous items found).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 08, 2024 Jul 08, 2024

Copy link to clipboard

Copied

Whoops sorry forgot something.

 

var currentslotnum:int = 1; stop(); function addToSlot(magicjewel:DisplayObject):void { if (!magicjewel["found"]) { magicjewel.x = root["itemslot1"].x; magicjewel.y = root["itemslot1"].y; magicjewel["found"] = true; root["itemInSlot1"] = magicjewel; // Store item in root currentslotnum++; } }

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines