2 page, page turn effect creation - cocos2d-x

trying to achieve a simple page turn effect where turning page is pivoted from center of screen i.e. just like a open book. I have completed half of the effect but come across a problem. Here's what I'm doing so far...
1) New scene at back (2 col)
2) Old scene at front (2 col)
3) Squish right hand col of old scene to center to reveal right hand side of new scene.
This is where I now have a problem... the next step would be to unsquish new scene on top of old scene on left hand side, but the new scene is currently behind the old. I think I need to some how achieve the following...
1) new scene right side at back
2) old scene right at front
3) new scene left side at front
4) old scene left at back
Then should be a case of pre setting widths and adjusting appropriately for animation.
Any ideas or pointers on how to achieve this...
Thanks in advance

Related

Highlighting Graph Points clicked on in HTML Canvas

I currently have an html page that produces a line graph inside a canvas element. I have also implemented a feature so that when you click on a point in the graph, a table below the canvas displays the information for that graph point, and clears if you click somewhere that isn't a graph point on the canvas. However, there is currently no indicator for what graph point you have selected.
I would like to make it so that the dot you click on either gets bigger, or highlighted, or something. Unfortunately, I don't think there's any way to do that on the one canvas without needing to redraw the entire graph afterwards. If I drew a bigger dot on top of the original, I would then need to erase it and replace it with the smaller one, as well as redrawing the segment of the line graph that was covered by the larger dot.
I was looking into using a second canvas on top of the first with identical dimensions, using a z-index to control which was on top. However, I don't know how this would affect the click event. If two canvasses are on top of each other, is it possible for the click event to register the lower canvas? Does it only register the higher one? I guess I could just change the click event to be for whichever canvas is on top, but keep all the code for drawing on the canvas the same.
Any advice for how to solve this problem?
Solved a few of my own questions.
Firstly, the click event will only recognize whichever canvas is on top. However, I did like I said, and changed my click event to be for the top canvas, while leaving all instructions on the inside to be for the top canvas. Thank goodness I didn't use the 'this' keyword, or the change would have been much more annoying.
To make the graph points highlight, I first added a second canvas on top of my first one, placing them on top of each other by making their positions "absolute" and giving them a z-index of 0 and 1 respectively. Then, inside the if statement where the original click event recognized that a point had been clicked on, I told the top canvas to draw a larger dot on the same coordinates as the first dot (which I had saved in an array). First, I had it clear the top canvas though, so any other highlighted dots would no longer be highlighted. If the canvas was clicked on somewhere other than a dot, nothing was highlighted.

Actionscript 3 - how to change existing MovieClips registration point

Edit: If you're going to downvote, at least explain why -.-
I have a MovieClip in the Library. I right clicked the MC and clicked 'edit'.. According to tutorials I read, apparently now I am supposed to move a circle / crosshair? I cannot move the circle / crosshair (I see it, but I can't move it), the only thing I can move right now is the object itself, how do I change the registration point?
When I first created the MC, it showed my a grid and asked where I want the registration point, is there a way to get that grid again which maps the registration point?
Edit: According to this post:
Change the position of the registration point in Flash CS5
I'm supposed to just move the object in relation to the crosshair and that the crosshair signifies the registration point, which is incorrect. When I do that, in moves the entire movieclip and it doesn't change the registration point.
Note: I am using Flash CS5
You can't "move" registration point, but you can move all inner clip content over it. Those silly crosshairs "pivots" work only in editor -- real registration point is always {0, 0} in clip local coordinate system.

How can i move code from a frame to another so i can create a menu?

i'm creating a videogame and so far i've been messing with it on the frame 1 since it's code just needed a frame to run, altho, now i have come to the place where i want to create a menu, and so i was thinking about coding it each frame being a menu and using gotoAndStop() to jump in between frames. Problem is, if i move my frame 1 to, let's say, frame 10 so i can play main menu at frame 1 the code stops working. I am very confused on what i should do and i'm not sure i am even being clear enough.
Should i place full code here, let me know.
How can i move the code from frame to frame 10 properly so it still works!
Forget the Frame approach. Nest your menu inside a MovieCLip, there u can use as many frames as u need and add that in your Main Frame.
It would be better to forget Framescript alltogether and use a Document Class, especially for a Game!
To your problem, dont put any keyframes other then the First one (with the code in it) in your actionsLayer. Put the stop() commmands und menu functions in a sepperate layer

How to scroll drag&drop-able objects based solely on their current position on the stage at the time the user scrolls

I'm working in Flash with Actionscript 3. I have a class of objects. Let's say the class is called "apple." At runtime, a number of instances of "apple" are generated on the left half of the stage. Every instance of "apple" can be dragged and dropped anywhere on the stage. Both the left and right halves of the stage have other art on them. What I am trying to construct is some mechanism by which the user can scroll up and down on ONLY the right (as in opposed to left) half of the stage, so that both the art on the right half of the stage and all instances of "apple" currently on the right half of the stage move in unison, while the art and instances of "apple" on the left half of the stage remain stationary. Any advice at all on what kinds of solutions I should be looking into would be greatly appreciated.
In short: You can use hitTestObject to test whether or not the currently dragged/dropped apple ended up on the right side of the screen. Create an array and store the instancenames of the apples on the right side. When the right side scrolls, move the apples in the array accordingly. This can be done by tracking y-coordinates.

Flash - SideScroller Turret Math

I'm working on a side scroller, and for the enemy I'm making a turret. I'm trying to make the turret aim at the player but I cant seem to get it right. Below is a rough sketch of what I want to achieve:
I want the barrel (dark blue), to aim/rotate to its pointing at the player.
I have uploaded a YouTube video of my scene:
http://www.youtube.com/watch?v=eeP47VoX9uA&feature=youtu.be
This is what I have so far (loop):
function enterFrameHandler(e : Event) : void{
_turretBarrel.rotation = Math.atan2(enTarget.x, enTarget.y) * 180/Math.PI;
}
What this does is only rotate the barrel when I jump, and the barrel isn't even aiming at the player, also the barrel doesn't change rotation when I walk on the other side of the turret.
My enTarget.x is always central to the stage and the scene (including the turret) moves around the player left and right (x)... Only the enTarget.y moves (jump/high platform).
I'm slightly new to Flash and ActionScript. If anyone could help me out, or point me in the right direction then that would be great.
Thanks
1) Make sure you got the right numbers and the position of the avatar and the turret are in the same coordinate space. A simple trace of each would do. In this case you probably want the world (relative to stage) position of both clips. Make sure they make sense compared to top left corner of the screen (0, 0).
2) Remember that _turretBarrel.rotation is a rotation that ranges from -180 to 180 so this would need to be taken into consideration when calculating angles.
3) Make sure you use the corresponding degrees/radians where appropriate.
4) force focus on avatar, run the game and see if the bounds looks ok. Then do the same thing with the turret.
Another good thing in general for debugging purposes is to setup some kind of debug graphics. i.e. draw a line of what you think is the direction vector to verify your numbers and calculations.
On a side note:
This is what the majority of programming is; Debugging. Assume nothing but hard facts, get your numbers from the debugger (probably quicker), or trace output. If you're still using the horrible flash professional IDE. I would really recommend getting one with a proper debugger like FlashDevelop (free) or Flash Builder (commercial)
Oliver, it looks like you are calculating the tangens of wrong angle (between player and X-axis). You need something like the following:
function enterFrameHandler(e : Event) : void{
_turretBarrel.rotation = Math.atan2(enTarget.x - barrel.x, enTarget.y - barrel.y) * 180/Math.PI;
}