Make a ScrollPane Menu with libgdx? - libgdx

I am making a MenuGame choosing level by ScrollPane(libGDX).
I want to add a Button using ScrollPane like the game "Cut the Rop", or "Tap The Frog".
A buttonlevel may be : Locking buttonlevel, rank starlevel (player played that level, and had 1, 2 or 3 stars ..., Unlock buttonlevel.
I had levelimages, lockimage, star and I have to make a lot of image for a level (locking Image Level, 0 stars ImageLevel, 1 star Level...).
How can I make that buttonlevels more simply ?

Related

AS3 Swap depths in Flash IDE without destroying movieclips

I have two movieclips, one is on top, one is on bottom. The top one is set to the second frame. I move it to the z axis bottom on the next frame, and for the remaining frames it plays all frames like it has been reset without any code (like I didn't tell it gotoAndStop(2)).
Image example: http://i.imgur.com/mQ8f5uT.gif (hard to tell by the frame rate, but the dark green box starts playing as if I didn't set it's frame once I move it below)
I know it doesn't have that issue when I code the depth swapping with setChildIndex, but the animations are lost.
If you're wondering, it's a simplified issue of a larger moving character sprite animation that I would like to swap depths of movie clips in the animation without resetting the movie clips underneath the depth change. So I'm not really looking for a work around per se, unless there's a well design solution and not a band aid "hack."
I think I didn't understand your question fully. A MovieClip will keep playing or keep being stopped no matter what you do with it, even if it was removed from the scene. I made a simple example which shows that MovieClip state is not affected by depth change.
The working SWF is here to test: http://zdg.ru/tmp/updown.swf
And the code is:
import flash.events.MouseEvent;
var is_playing:Boolean = true;
btn_toggle.addEventListener(MouseEvent.CLICK, doToggle);
btn_updown.addEventListener(MouseEvent.CLICK, doUpdown);
function doToggle(evt:MouseEvent) {
if (is_playing) mv_test.stop(); else mv_test.play();
is_playing = !is_playing;
}
function doUpdown(evt:MouseEvent) {
var tmp:int = getChildIndex(mv_block);
setChildIndex(mv_block, getChildIndex(mv_test));
setChildIndex(mv_test, tmp);
}

cocos2d, reorder children in different batch node

I am creating a fighting game. I've got a spritesheet for the hero and a spritesheet for a monster. Since both will be able to do multiple attacks I would like to avoid to merge them in a single spritesheet. And I am intending to create more characters.
Now I am creating a SpriteBatchNode for each spritesheet and add them to layer.
CCLayer* stage = CCLayer::create();
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("character_hero.plist");
this->characterHeroBatchNode = CCSpriteBatchNode::create("character_hero.pvr.ccz");
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("character_monster.plist");
this->characterMonsterBatchNode = CCSpriteBatchNode::create("character_monster.pvr.ccz");
stage->addChild(characterHeroBatchNode);
stage->addChild(characterMonsterBatchNode);
Now I have one sprite in characterHeroBatchNode and multiple in characterMonsterBatchNode.
How can I reorder the monsters and the heros z-Order based on their PositionY attribute.
For example>
monster1->setPositionY(10); // In monster batch node
hero->setPositionY(24); // In hero batch node
monster2->setPositionY(43); // In monster batch node
I want the monster 1 behind the hero. And the hero behind monster2.
In the past, I've had to create games where I wanted some sprites in the foreground and others in the background. The sprites were in different sheets, like you have them.
To get them in the order I wanted, I put the "front" sprites into one CCLayer and the "back" sprites into another CCLayer. I added the layers to the scene in the order I wanted them to appear. I also manipulated each the respective layers to make them fade in/out as needed. So you could have the hero in the scene and then have the enemies appear behind him.
If you want to mix and match, you can have 3 layers, one for the "middle ground", one for "front", and one for "back", and dynamically move the sprites between the layers.
Was this what you were looking for?
If I understand what you're asking, the answer is, you can't. Consider each CCSpriteBatchNode to be its own container. You can adjust the Z order of the sprites inside the CCSpriteBatchNode, but when you add the batch to the CCLayer the whole CCSpriteBatchNode is applied to the CCLayer in whatever Z order you added it at. So in order to do what you want you would need another batch of monsters. Or use CCSprites and add/adjust them on the CCLayer in the way you want, but then you obviously lose the CCSpriteBatchNode benefits.

AS3: How to make movieclip appear on middle of a separate mc container?

I've been searching and having trouble doing this the right way.So my player has 2 arms which are joined in one mc. Now I'm trying to make the body(which is doesn't belong on the container mc) go between them, so it's like R arm first then body then L arm. The 2 arms rotate on mouse direction, i don't want the body too. Any ideas what way I should go?
EDIT:
please see my sample image
The checked thing is the result I'm looking for. But since the 2 arms is combined on one MC, I can't make the body appear on the middle between the 2 arms.
You should change your nesting model like this:
And then store your arms in an Array or a Vector, and change every arm's rotation separately.
It's the only way

How to insert a movie on button click - AS3

I'v been working on a strobe website for a while now http://strobepage.com/
I want to allow users to select their own colours for the strobe, This Basically means I will easily be able to cover way more colour combinations and take up less room on the site..
So far I have tried making 2 movie clips, one for each colour.. and refering to it as an instance and as a movie clip as a whole ( MovieClip(colour1) ) to change its colour.. this works, but only in that specific instance, when the user clicks "next" to progress to the next frame of the ROOT movie (which displays the interchanging movie clips) the movie clips have reverted back to their original state..
Is there possibly a way to PERMANENTLY colour a movie clip on button press... I seem to think there isnt.. This is where i thought, hey, why not make a bunch of movie clips that contain different colours, and on button press, one of these movie clips, is inserted into another movie clip that will have 2 frames that interchange between the movie clips that the user has selected... Only, I have no idea how to do this, and whether its possible or not..
I hope i have explained this in an understandable way.. theres lots of movieclips lol..
anyway, thanks in advance for anyone who can come up with a solution :D
Please give an AS3 example of what you are explaining :D
Create movie clip for each color and place on the same x, y.
Now keep them all visible=false and make particular mc to visible=true. Use colortranform to reflect the changes on other mc's.
If you want to keep it light and easy to maintain, you'll want to use code, not timeline frames to get your colors (this will also ensure faster performing strobes). This is quite easy to accomplish with ColorTransform. Below is a function I've written that encapsulates that operation; accepting the object you want to color as the first argument, and a hexidecimal value of the color as the second.
function tint(obj:Object, color:uint):void {
/* Colors the object using transform */
// Pull the individual primaries
var r:Number = (color >> 16 ) & 0xFF;
var g:Number = (color >> 8) & 0xFF;
var b:Number = color & 0xFF;
// Apply if valid
if (obj.hasOwnProperty("transform")) {
obj.transform.colorTransform = new ColorTransform(0,0,0,1,r,g,b,0);
}
}
In example, let's assume you have a DisplayObject on stage called "box", and wanted to color it a bright blue, you'd do the following:
tint(box, 0x1b8afc);
Hope that helps.

How do I bring 1 of 3 movie clips to the front and make it stay there? (Flash CS5, AS 3.0)

I have three movie clips that I want to bring to front when I click on the associated tag. Flash cs5 and actionscript 3.0. The coding for each looks like this:
status_mc.status_btn.addEventListener(MouseEvent.CLICK, callFunction_stat);
function callFunction_stat(e:MouseEvent): void {
if (getChildIndex(status_mc) == 0) {setChildIndex(status_mc, 1) } else {setChildIndex(status_mc, 0)} ;
}
This sends the movie clip /back/ instead of forwards though it does allow me to view each clip on top. My question is, how do I bring each of the 3 movie clips to the front when I click on it, and if it /is/ in the front, make it remain so/no change when clicked?
To bring a display object to the front (IE:on top of all other display objects) you simply need to addChild(status_mc)