RPG Maker MV - Checking which frame of a character sheet is currently active - rpgmakermv

I have a character sheet for the player that triggers when they are idle for a while. The sheet has them going from standing to laying down in 6 frames, sleeping for 3 frames and then standing back up in 7 frames.
I'm looking to pause the animation when it reaches the 9th frame without using timers (as the character sheet may change in the future). Is there a function that will let me query which animation frame is currently being displayed?
Alternatively, is there a way to know if a character sheet has reached the last frame and is about to return to the first frame. I need to know when this animation has finished a cycle so I can smoothly transition back into the walking animation.

I'm extending Modern Algebra's ExtraMovementFrames plugin, so the solution ended up being to capture the output of this:
var patternIndex = (this._pattern % this.emfCharacterState().pattern.length);
which uses the ._pattern property of the player, modulo the length of the animation.
I then used this.setStepAnime(false); to pause the walking animation of the character once it reached the desired frame.
Also asked this on the rpg maker mv forums: https://forums.rpgmakerweb.com/index.php?threads/checking-which-frame-of-a-character-sheet-is-currently-active.115662/

Related

Marquee (scrolling) Text in SwiftUI

I am having difficulties implementing the marquee (scrolling) text view in SwiftUI. The problem is that the text needs to stay in the original (0) position for 2 seconds and the starts moving to the left, show up on the right and continue scrolling until the 0 position and wait for 2 seconds again.
You can work with what's in this video to get something working, but honestly it's difficult to make it work with varying screen sizes if your view is in any way responsive. But if you are using the foundation in that video for the animations and combining that with a geometry reader to get your zero position and rightmost entry point position, you could get the scroll positioning correct.
As for starting and stopping, I would suggest you use a Timer to toggle a boolean #State variable called scrollText to start/stop the animation 2 seconds after its duration. You would start by first toggling the animation in .onAppear, like this:
Text("Hello World")
.offset(x: scrollText ? zeroPoint : screenEntryPoint)
.animation(Animation.linear(duration: 8).repeatForever(autoreverses: false))
.onAppear {
self.scrollText.toggle()
}
If you then set a timer for 10 seconds to toggle scrollText, you would be able to get the animation to run for 8s, pause 2 seconds, and then run again.
Please note that to make marquee text work, you also need to REPEAT the text twice, so that the text will animate in from the right while it's also leaving from the left. Good luck!

Start/Stop a sprite animation from/on a specific frame in Spritekit

​I have a sprite animation of 30 frames, 6 of these frames are keyframes and the rest are transitions from keyframe to keyframe.
I am trying to figure out how to do the following:
When button is pressed the sprite starts animating. Animation will run at least once and then it will stop the animation on a randomly chosen keyframe.
When button is pressed again, animation will start from the last chosen keyframe and will run 1 complete cycle and then stops again on a randomly chosen keyframe.
I've found a similar question here but that was asked in 2014. Did Swift and Spritekit change enough in 3 years to make it possible?
Edit:
#Alessandro Ornano
I've tried this:
var roll1Textures = ["Roll1Motion0", "Roll1Motion1", "Roll1Motion2", "Roll1Motion3", "Roll1Motion4", "Roll1Motion5", "Roll1Motion6", "Roll1Motion7", "Roll1Motion8", "Roll1Motion9", "Roll1Motion10", "Roll1Motion11", "Roll1Motion12", "Roll1Motion13", "Roll1Motion14", "Roll1Motion15", "Roll1Motion16", "Roll1Motion17", "Roll1Motion18", "Roll1Motion19", "Roll1Motion20", "Roll1Motion21", "Roll1Motion22", "Roll1Motion23", "Roll1Motion24", "Roll1Motion25", "Roll1Motion26", "Roll1Motion27", "Roll1Motion28", "Roll1Motion29"]
let roll1Animation = SKAction.animate(with: Array(roll1Textures[0...5]), timePerFrame: 0.06, resize:false, restore:false)
But I get an error message: Cannot use instance member 'roll1Textures' within property initialiser; property initialisers run before 'self' is available.
How did I implement your code in a wrong way?
I don't know if it could be useful to your game but now in Swift you can also do in one line:
let animation = SKAction.animate(with: Array(textures[0...5]), timePerFrame: 0.06, resize:false, restore:false)
In other words you can create an array slice composed by your specific range then re-create the array of textures with Array

Pygame: Character Centered Movement System (Diablo II like click-to-move)

I am currently working on a new RPG game using Pygame (my aim here is really to learn how to use object oriented programming). I started a few days ago and developed a movement system where the player clicks a location and the character sprite goes to that location and stops when it get's there by checking if the sprite 'collides' with the mouse position.
I quickly found however that this greatly limited the world size (to the app window size).
I started having a look into making a movement system where the background would move with respect to the player, hence providing the illusion of movement.
I managed to achieve this by creating a variable keeping track of my background map position. The map is much bigger than the app window. And each time I want my player to move I offset the background by the speed of the player in the opposite direction.
My next problem now is that I can't get my character to stop moving... because the character sprite never actually reaches the last position clicked by the mouse, since it is the background that is moving, not the character sprite.
I was thinking of spending some time coding in a variable that would keep track of how many displacements it would take the character sprite to reach the mouse clicked position if it was to move. Since the background moves at the character sprite's speed it would take as many displacement of the background in the x and y directions to center the clicked position on the background to the character sprite at the center of the screen.
It would be something like that:
If MOUSEBUTTON clicked:
NM = set number of moves needed to reach the clicked position based on character sprite distance to click and character sprite speed.
If NM != 0:
Move background image
Else:
pass
This would mean that when my background has moved enough for the character sprite to now be just over the area of the background that was originally clicked by the player, the movement would stop since NM == 0.
I guess that my question is: Does that sound like a good idea or will it be a nightmare to handle the movement of other sprites and collisions ? And are there better tools in Pygame to achieve this movement system ?
I could also maybe use a clock and work out how many seconds the movements would take.
I guess that ultimately the whole challenge is dealing with a fixed reference point and make everything move around it, both with respect to this fixed reference, but also to their own. e.g. If two other sprites move toward one another, and the character of the player also "moves" then the movement of the other two sprites will have to depend both on the position of the other sprite and also on the offset of the background caused by the movement of the player's character.
An interesting topic which has been frying my brain for a few nights !
Thank you for your suggestions !
You actually asking for an opinion on game design. The way I look at it, nothing is impossible so go ahead and try your coding. Also it would be wise to look around at similar projects scattered around the net. You may be able to pick up a lot of tips without re inventing the wheel. Here is a good place to start.
scrolling mini map

how to change the position of player using left and right button when the player is jumping?

Cocos2d offers two ways to let the player jump up, but by using jumpto() and jumpby(), people could not change the position of the sprite any more when it is jumping up.
How to write a method so that the sprite can jump like the "Super Mario"?
Some time ago I contributed some cocos2d code which made CCMove and CCJump actions stackable. See here. Starting from cocos2d 2.1, you can apply a CCJump actions concurrently with other movements.
However, if you want to deeply fine tune how the controls of your game feel, I'd avoid using CCActions altogether and I'd manage the sprite.position directly by processing player input.
you have to check for two condition for making your player to jump, same as in Super Mario.
Condition 1)
Only jump button is pressed at that time in CCJumpTo action you have to give the next position as the current position , height and no. jumps as one.
id jump = [CCJumpTo actionWithDuration:1 position:ccp(player.position.x, player.position.y)) height:20 jumps:1];
Condition 2)
When jump and forward button is pressed at that time in CCJumpTo action you have to give the next position as the current position.x + the distance you want to cover by jump,this will be static all the time , height and no. jumps as one.
id jump = [CCJumpTo actionWithDuration:1 position:ccp(player.position.x+20, player.position.y)) height:20 jumps:1];
And at the end you have to run jump action on player, hope you found this as solution for your question...!!

Cocos2d scroll layer on Sprite drag

I have designed a small tutorial named "Stacker", As the name suggests, The game involves stacking blocks on each other. I have a large number of blocks to be stacked and hence all cant be accomodated in the screen itself... I m new to cocos2d and box2d but have managed to create a body with its adjoining sprite wen a user clicks on the screen. I have used MouseJoint to give movement to the body till the user performs the drag action that is till the user takes his finger off the screen.
The problem is that i need to follow the sprite (actually need the camera to follow the sprite) when the user drags it above the screen space, i referred the following links with no success... i guess wat i need is to move the body to a virtual coordinates which m not getting coz even if the screen does shift using the camera methods, but the sprite doesnt move with respect to the screen...
cocos2d forum link
flash concept but box2d
Can some1 guide me in case i need to have some pre-requisites before following camera in the manner i specified.. Thanx!
Ok Guys!
Got it guys! Had to take a global variable which records the increments per frame, The increments were equal to the layer movement which i did by setting the position of the layer to a unit less in every frame! Then set the Mouse join to the target which is (ScreenCoordinates + increment) dis too has to be done in every frame!
Done!
Cool method but needed a bit of brainstorming!!